Expression.TypeAs(Expression, Type) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Dönüştürme başarısız olursa sağlanan açık başvuruyu veya kutulama dönüştürmesini null temsil eden bir UnaryExpression oluşturur.
public:
static System::Linq::Expressions::UnaryExpression ^ TypeAs(System::Linq::Expressions::Expression ^ expression, Type ^ type);
public static System.Linq.Expressions.UnaryExpression TypeAs(System.Linq.Expressions.Expression expression, Type type);
static member TypeAs : System.Linq.Expressions.Expression * Type -> System.Linq.Expressions.UnaryExpression
Public Shared Function TypeAs (expression As Expression, type As Type) As UnaryExpression
Parametreler
- expression
- Expression
Özelliğinin Operand değerine eşit olarak ayarlanması için birExpression.
Döndürülenler
UnaryExpression özelliğine TypeAsNodeType eşit ve ve TypeOperand özellikleri belirtilen değerlere ayarlanmış bir.
Özel durumlar
expression veya type şeklindedir null.
Örnekler
Aşağıdaki örnek, null değer atanamayan bir UnaryExpression tamsayı ifadesinin TypeAs(Expression, Type) null atanabilir tamsayı türüne başvuru dönüştürmesini temsil eden bir oluşturmak için yönteminin nasıl kullanılacağını gösterir.
// Create a UnaryExpression that represents a
// conversion of an int to an int?.
System.Linq.Expressions.UnaryExpression typeAsExpression =
System.Linq.Expressions.Expression.TypeAs(
System.Linq.Expressions.Expression.Constant(34, typeof(int)),
typeof(int?));
Console.WriteLine(typeAsExpression.ToString());
// This code produces the following output:
//
// (34 As Nullable`1)
' Create a UnaryExpression that represents a reference
' conversion of an Integer to an Integer? (a nullable Integer).
Dim typeAsExpression As System.Linq.Expressions.UnaryExpression = _
System.Linq.Expressions.Expression.TypeAs( _
System.Linq.Expressions.Expression.Constant(34, Type.GetType("System.Int32")), _
Type.GetType("System.Nullable`1[System.Int32]"))
Console.WriteLine(typeAsExpression.ToString())
' This code produces the following output:
'
' (34 As Nullable`1)
Açıklamalar
Sonuçta MethodUnaryExpression elde edilen özelliği şeklindedir null.
IsLifted ve IsLiftedToNull özellikleri her ikisi de falseşeklindedir.