tags:

views:

436

answers:

4

We just shifted from VB to C# and I am having some troubles..!

Why can't I create a private static const void??

why is it not working?

 private static const void MyVoid(void void)
 { 
   try
   {
      this.void void = new void(void + void);
      return this.void;
   }
   catch (void)
   {
      Response.Write(void);
   }
 }
+1  A: 

void is the return type of "there is no return type". It is not a type in itself (as in int, bool etc.), but rather specifies it returns nothing.

Rob Cooper
A: 

it's because void is actually nothingness :) If you want to send nothing to methods. Do it MyVoid()

The same is for other lines in your method

Tamir
+6  A: 

C# doesn't let you declare a method to be const whatever its return type is, so your method declaration is incorrect.

You can't catch void either - you can only catch exception types.

Ditto void parameters etc.

Why do you think you need this?

Jon Skeet
+1  A: 

void is a reserved keyword for "return nothing"

http://msdn.microsoft.com/en-us/library/yah0tteb.aspx

here is the list of all reserved keywords http://msdn.microsoft.com/en-us/library/x53a06bb.aspx

think of Void like a Sub for C#

In C# we only have methods - which return something (VB Functions) or return nothing ie void (VB Sub)