TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# Default Expression

C# Default Expression for beginners and professionals with examples on overloading, method overriding, inheritance, aggregation, base, polymorphism, sealed, abstract, interface, namespaces, exception handling, file io, collections, multithreading, reflection etc.

<< Back to C-SHARP

C# Default Expression

C# 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 Syntax

public sealed class DefaultExpression : Expression

It provides following properties and methods.

C# DefaultExpression Properties

Name Description
CanReduce This property is inherited from Expressionn. It Indicates that the node can be reduced to a simpler node.
NodeType It is used to return the node type of this expression.
Type Gets the static type of the expression that this Expression represents.

C# DefaultExpression Methods

Name Description
Accept(ExpressionVisitor) It is used to dispatch the specific visit method for this node type.
Equals(Object) It determines whether the specified object is equal to the current object or not.
GetHashCode() This method serves as the default hash function.
GetType() It is used to get the type of the current instance.
Reduce() It is used to reduce this node to a simpler expression.
ReduceAndCheck() It is used to reduce this node to a simpler expression by explicit checking.
ReduceExtensions() It reduces the expression to a known node type.
ToString() It is used to return a string representation of the Expression.
VisitChildren(ExpressionVisitor) It reduces the node and then calls the visitor delegate on the reduced expression.

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 Example

using 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




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf