DefaultExpression Classe
In questo articolo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Rappresenta il valore predefinito di un tipo o un'espressione vuota.
public ref class DefaultExpression sealed : System::Linq::Expressions::Expression
public sealed class DefaultExpression : System.Linq.Expressions.Expression
type DefaultExpression = class
inherit Expression
Public NotInheritable Class DefaultExpression
Inherits Expression
- Ereditarietà
Nell'esempio di codice seguente viene illustrato come creare un'espressione che rappresenta un valore predefinito per un determinato tipo usando il Default metodo .
// Add the following directive to your file:
// using System.Linq.Expressions;
// This expression represents the default value of a type
// (0 for integer, null for a string, etc.)
Expression defaultExpr = Expression.Default(
typeof(byte)
);
// Print out the expression.
Console.WriteLine(defaultExpr.ToString());
// The following statement first creates an expression tree,
// then compiles it, and then executes it.
Console.WriteLine(
Expression.Lambda<Func<byte>>(defaultExpr).Compile()());
// This code example produces the following output:
//
// default(Byte)
// 0
' Add the following directive to your file:
' Imports System.Linq.Expressions
' This expression represents the default value of a type
' (0 for integer, null for a string, and so on).
Dim defaultExpr As Expression = Expression.Default(
GetType(Byte)
)
' Print the expression.
Console.WriteLine(defaultExpr.ToString())
' The following statement first creates an expression tree,
' then compiles it, and then executes it.
Console.WriteLine(
Expression.Lambda(Of Func(Of Byte))(defaultExpr).Compile()())
' This code example produces the following output:
'
' default(Byte)
' 0
Can |
Indica che il nodo può essere ridotto a un nodo più semplice. Se restituisce true, è possibile chiamare Reduce() per generare la forma ridotta. (Ereditato da Expression) |
Node |
Restituisce il tipo di nodo dell'espressione. I nodi di estensione devono restituire Extension quando si esegue l'override di questo metodo. |
Type |
Ottiene il tipo statico dell'espressione rappresentata da Expression. |
Accept(Expression |
Invia al metodo Visit specifico per questo tipo di nodo. Ad esempio, MethodCallExpression chiama VisitMethodCall(MethodCallExpression). (Ereditato da Expression) |
Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
Get |
Funge da funzione hash predefinita. (Ereditato da Object) |
Get |
Ottiene l'oggetto Type dell'istanza corrente. (Ereditato da Object) |
Memberwise |
Crea una copia superficiale dell'oggetto Object corrente. (Ereditato da Object) |
Reduce() |
Riduce questo nodo a un'espressione più semplice. Se CanReduce restituisce true, deve essere restituita un'espressione valida. Questo metodo può restituire un altro nodo che deve essere a sua volta ridotto. (Ereditato da Expression) |
Reduce |
Riduce questo nodo a un'espressione più semplice. Se CanReduce restituisce true, deve essere restituita un'espressione valida. Questo metodo può restituire un altro nodo che deve essere a sua volta ridotto. (Ereditato da Expression) |
Reduce |
Riduce l'espressione a un tipo di nodo noto (diverso da un nodo di estensione) o restituisce solo l'espressione se è già un tipo noto. (Ereditato da Expression) |
To |
Restituisce una rappresentazione testuale di Expression. (Ereditato da Expression) |
Visit |
Riduce il nodo, quindi chiama il delegato del visitatore sull'espressione ridotta. Se il nodo non è riducibile, il metodo genera un'eccezione. (Ereditato da Expression) |
Prodotto | Versioni |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: