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

We just moved from VB to C # and I was having trouble ..!

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

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);
   }
 }

      

-2


source to share


4 answers


C # does not allow you to declare a method const

whatever type it returns, so your method declaration is incorrect.

You can't catch either void

- you can only catch exception types.



Ditto void parameters etc.

Why do you think you need this?

+6


source


void

is a return type ", there is no return type . It is not a type per se (as in int

, bool

etc.), but rather indicates that it does not return anything.



+2


source


this is because void is actually non-being :) If you want to send nothing to methods. Do it MyVoid ()

Same for other lines in your method

+1


source


void is a reserved keyword for "return nothing"

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

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

think of Void as Sub for C #

In C # we only have methods - which return something (VB functions) or return nothing, i.e. void (VB Sub)

+1


source







All Articles