1.

Why Do I Get An Error (cs1006) When Trying To Declare A Method Without Specifying A Return Type?

Answer»

If you LEAVE off the RETURN type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that RETURNS nothing, use VOID. The following is an example: // This RESULTS in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)

If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)



Discussion

No Comment Found