nikhil kansal
Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
By nikhil kansal in C# on Jul 14 2006
  • Jul, 2006 14

    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)

    • 1
  • Jigar Tailor
    Apr, 2015 14

    if you create method without return type compiler predict it as constructor and match the name of class with the method, that will miss match and gives error

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS