ElementInit Class
Represents an initializer for a single element of an IEnumerable collection.
Assembly: System.Core (in System.Core.dll)
| Name | Description | |
|---|---|---|
![]() | AddMethod | Gets the instance method that is used to add an element to an IEnumerable collection. |
![]() | Arguments | Gets the collection of arguments that are passed to a method that adds an element to an IEnumerable collection. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ToString() | Returns a textual representation of an ElementInit object.(Overrides Object.ToString().) |
![]() | Update(IEnumerable(Of Expression)) | Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression. |
| Name | Description | |
|---|---|---|
![]() ![]() | IArgumentProvider.GetArgument(Int32) | Returns the argument at index, throwing if index is out of bounds. You should not use this member. It is only public due to assembly refactoring, and it is used internally for performance optimizations. |
![]() ![]() | IArgumentProvider.ArgumentCount | Returns the number of arguments to the expression tree node. You should not use this member. It is only public due to assembly refactoring, and it is used internally for performance optimizations. |
The following example creates an ElementInit that represents the initialization of an element of a dictionary collection.
Dim tree As String = "maple" Dim addMethod As System.Reflection.MethodInfo = _ Type.GetType("System.Collections.Generic.Dictionary`2[System.Int32, System.String]").GetMethod("Add") ' Create an ElementInit that represents calling ' Dictionary(Of Integer, String).Add(tree.Length, tree). Dim elementInit As System.Linq.Expressions.ElementInit = _ System.Linq.Expressions.Expression.ElementInit( _ addMethod, _ System.Linq.Expressions.Expression.Constant(tree.Length), _ System.Linq.Expressions.Expression.Constant(tree)) Console.WriteLine(elementInit.ToString()) ' This code produces the following output: ' ' Void Add(Int32, System.String)(5,"maple")
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.




