The default value for a dynamic type?

What is the default value for a variable declared as dynamic, for example. private dynamic banana; ?

Can one rely on the default() function when a type is determined at runtime?

The reason I need to find the default value is to declare a dynamic member of the class that I want to set once (but not as readonly ), and then use it many times.

How to check if a dynamic variable is set to a value other than the default without knowing what the type of execution will be?

Google didn't come up with anything: S

Thanks in advance.

+6
source share
1 answer

This is null .

 dynamic blah; Console.Write(blah); // crash Console.Write(blah.GetType()); // NullRef 

.. is that what you had in mind?

+5
source

All Articles