class - C# constructor gives "Method must have a return type" -


i been trying learn how create class in c#. created class , tried create constructor go along class. when created constructor in class, compiler keeps thinking i'm trying create method instead.

public product(string code, string description, decimal price) {     this.code = code;     this.description = description;      this.price = price; } 

error 1 method must have return type

in form, tried instantiate object go along it.

productclass product1 = new product("cs10", "murach's c# 2010", 54.60m); 

but it's still giving me error.

why isn't compiler recognizing i'm trying create constructor instead of method? because don't have accessor property go along it? thank you.

constructor name must same class has defined.
if class name productclass, change construcor definition as:

public productclass(string code, string description, decimal price)     {         this.code = code;         this.description = description;          this.price = price;     } 

have @ this more detail.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -