C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# Default ExpressionC# default expression is a class (DefaultExpression) that is used to represent default value of an empty expression. It is a sub class of System.Linq.Expressions.Expression namespace. To get default value of an expression, Expression class provides a static method Default(Type) that returns instance of DefaultExpression class. C# DefaultExpression class Syntaxpublic sealed class DefaultExpression : Expression It provides following properties and methods. C# DefaultExpression Properties
C# DefaultExpression Methods
The Expression.Default() method has the following signature. public static DefaultExpression Default(Type type) It takes a parameter of System.Type type and returns an instance of DefaultExpression class. C# Default Expression Exampleusing System; using System.Linq.Expressions; namespace CSharpFeatures { class AsynchronousMethod { public static void Main(string[] args = default) { Expression defaultExpression = Expression.Default(typeof(int)); show(defaultExpression); } static void show(Expression defaultExpression) { // Default expression properties and methods Console.WriteLine("Instace: " + defaultExpression); Console.WriteLine("Type: " + defaultExpression.Type); Console.WriteLine("Can reduce: " + defaultExpression.CanReduce); Console.WriteLine("Instance type: " + defaultExpression.GetType()); Console.WriteLine("Node type: " + defaultExpression.NodeType); } } } Output: Instace: default(Int32) Type: System.Int32 Can reduce: False Instance type: System.Linq.Expressions.DefaultExpression Node type: Default
Next TopicC# Programs
|