DefaultExpression クラス

定義

型または空の式の既定値を表します。

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
継承
DefaultExpression

次のコード例は、メソッドを使用して、特定の型の既定値を表す式を作成する方法を Default 示しています。

// 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

プロパティ

CanReduce

ノードをより単純なノードに変形できることを示します。 これが true を返す場合、Reduce() を呼び出して単純化された形式を生成できます。

(継承元 Expression)
NodeType

この式のノード型を返します。 拡張ノードは、このメソッドをオーバーライドする際に Extension を返す必要があります。

Type

この Expression が表す式の静的な型を取得します。

メソッド

Accept(ExpressionVisitor)

このノード型の特定の Visit メソッドにデスパッチします。 たとえば、MethodCallExpressionVisitMethodCall(MethodCallExpression) を呼び出します。

(継承元 Expression)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
Reduce()

このノードをより単純な式に変形します。 CanReduce が true を返す場合、これは有効な式を返します。 このメソッドは、それ自体も単純化する必要がある別のノードを返す場合があります。

(継承元 Expression)
ReduceAndCheck()

このノードをより単純な式に変形します。 CanReduce が true を返す場合、これは有効な式を返します。 このメソッドは、それ自体も単純化する必要がある別のノードを返す場合があります。

(継承元 Expression)
ReduceExtensions()

式を既知のノード型 (拡張ノードではない型) に単純化し、それが既に既知の型である場合は単に式を返します。

(継承元 Expression)
ToString()

Expression のテキスト表現を返します。

(継承元 Expression)
VisitChildren(ExpressionVisitor)

ノードを単純化し、単純化された式の visitor デリゲートを呼び出します。 ノードを単純化できない場合、このメソッドは例外をスローします。

(継承元 Expression)

適用対象