Sunday, March 29, 2015

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?

Question:Why do I get an error (CS1006) when trying to declare a method without specifying a return type??

Answer: </P><P align=justify>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</P><P align=justify>public static staticMethod (mainStatic obj)</P><P align=justify>// This will work as wanted</P><P align=justify>public static void staticMethod (mainStatic obj)

Tags:Interview Questions, Microsoft, C#,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement




Medical Billing Software

Hospital Management System Software

Hospital Management System (HMS) Software is developed for multispeciality hospitals, to cover a wide range of hospital administration and management processes with financial accounting, voucher entry, pharmacy, patients module etc features...

No comments:

Post a Comment