|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
ListInitExpression, classe
.NET Framework 4.5
Espace de noms : System.Linq.Expressions
Assembly : System.Core (dans System.Core.dll)
Le type ListInitExpression expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | CanReduce | |
![]() ![]() ![]() | Initializers | |
![]() ![]() ![]() | NewExpression | |
![]() ![]() ![]() | NodeType | |
![]() ![]() ![]() | Type |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | Accept | |
![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() | GetHashCode | |
![]() ![]() ![]() | GetType | |
![]() ![]() ![]() | Reduce | |
![]() ![]() ![]() | ReduceAndCheck | |
![]() ![]() ![]() | ReduceExtensions | |
![]() ![]() ![]() | ToString | |
![]() ![]() ![]() | Update | |
![]() ![]() ![]() | VisitChildren |
string tree1 = "maple"; string tree2 = "oak"; System.Reflection.MethodInfo addMethod = typeof(Dictionary<int, string>).GetMethod("Add"); // Create two ElementInit objects that represent the // two key-value pairs to add to the Dictionary. System.Linq.Expressions.ElementInit elementInit1 = System.Linq.Expressions.Expression.ElementInit( addMethod, System.Linq.Expressions.Expression.Constant(tree1.Length), System.Linq.Expressions.Expression.Constant(tree1)); System.Linq.Expressions.ElementInit elementInit2 = System.Linq.Expressions.Expression.ElementInit( addMethod, System.Linq.Expressions.Expression.Constant(tree2.Length), System.Linq.Expressions.Expression.Constant(tree2)); // Create a NewExpression that represents constructing // a new instance of Dictionary<int, string>. System.Linq.Expressions.NewExpression newDictionaryExpression = System.Linq.Expressions.Expression.New(typeof(Dictionary<int, string>)); // Create a ListInitExpression that represents initializing // a new Dictionary<> instance with two key-value pairs. System.Linq.Expressions.ListInitExpression listInitExpression = System.Linq.Expressions.Expression.ListInit( newDictionaryExpression, elementInit1, elementInit2); Console.WriteLine(listInitExpression.ToString()); // This code produces the following output: // // new Dictionary`2() {Void Add(Int32, System.String)(5,"maple"), // Void Add(Int32, System.String)(3,"oak")}
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.


