On System.Void

Did you know there’s actually a System.Void type? You could use it in some exotic scenarios to test if a value is of type void. One example where you might need this is in ContextBoundObject objects where you interfere with the messaging.

However, this bit of code will not work:

methodReturnMessage.ReturnValue is System.Void

You cannot use System.Void directly in C#, but will have to revert to typeof(void) instead. The code needs to use the variant of comparing type objects (the only available option in Visual Basic .NET):

methodReturnMessage.ReturnValue.GetType() != typeof(void)

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s