Error coming c# Please look

by 2 replies
3
Hello

I am new to C# so i was just doing practice with tutorials i get this error:

"method must have return type"

for those two places:
public emp()
public emp(string varname,int varage)


Help will be apprecited thanks!

#programming #coming #error
  • You're trying to create a constructor named "emp", but your class is not named "emp", it's named "Program". A class and its constructor method have the same name.

    Since this method does not match any class name, the compiler expects you're creating a normal method, not a constructor, and methods have return types.
    • [ 1 ] Thanks
    • [1] reply

Next Topics on Trending Feed