Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
.NET Framework Class Library
MethodCallExpression Class

Updated: November 2007

Represents calling a method.

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)

Visual Basic (Declaration)
Public NotInheritable Class MethodCallExpression _
    Inherits Expression
Visual Basic (Usage)
Dim instance As MethodCallExpression
C#
public sealed class MethodCallExpression : Expression
Visual C++
public ref class MethodCallExpression sealed : public Expression
J#
public final class MethodCallExpression extends Expression
JScript
public final class MethodCallExpression extends Expression

Use the Call, ArrayIndex, or ArrayIndex factory method to create a MethodCallExpression.

The value of the NodeType property of a MethodCallExpression object is Call.

The following example creates a MethodCallExpression object that represents indexing into a two-dimensional array.

Visual Basic
Dim gradeArray(,) As String = _
    {{"chemistry", "history", "mathematics"}, {"78", "61", "82"}}

Dim arrayExpression As System.Linq.Expressions.Expression = _
    System.Linq.Expressions.Expression.Constant(gradeArray)

' Create a MethodCallExpression that represents indexing
' into the two-dimensional array 'gradeArray' at (0, 2).
' Executing the expression would return "mathematics".
Dim methodCallExpression As System.Linq.Expressions.MethodCallExpression = _
    System.Linq.Expressions.Expression.ArrayIndex( _
        arrayExpression, _
        System.Linq.Expressions.Expression.Constant(0), _
        System.Linq.Expressions.Expression.Constant(2))

Console.WriteLine(methodCallExpression.ToString())

' This code produces the following output:
'
' value(System.String[,]).Get(0, 2)

C#
string[,] gradeArray =
    { {"chemistry", "history", "mathematics"}, {"78", "61", "82"} };

System.Linq.Expressions.Expression arrayExpression =
    System.Linq.Expressions.Expression.Constant(gradeArray);

// Create a MethodCallExpression that represents indexing
// into the two-dimensional array 'gradeArray' at (0, 2).
// Executing the expression would return "mathematics".
System.Linq.Expressions.MethodCallExpression methodCallExpression =
    System.Linq.Expressions.Expression.ArrayIndex(
        arrayExpression,
        System.Linq.Expressions.Expression.Constant(0),
        System.Linq.Expressions.Expression.Constant(2));

Console.WriteLine(methodCallExpression.ToString());

// This code produces the following output:
//
// value(System.String[,]).Get(0, 2)

System..::.Object
  System.Linq.Expressions..::.Expression
    System.Linq.Expressions..::.MethodCallExpression
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista, Windows XP SP2, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker