c# - Multiple Interfaces -
I am trying to input an interface into a class so that I can return their information, in this case, An age and a name Although I have participated in a problem where there is no matching return type in my C1 class, and I do not understand what to do now because I have seen that there are only 1 interface or multiple classes. Even I have so far:
Interface IWhatsMyAgeAgain {int GetAge (); } Interface ISAMInam {string GetName (); } Class C1: IWhatsMyAgeAgain, ISayMyName {Public Int Age; The name of the public string; Public string getName () {name return;} public integer GetAge () {age;;}} class program {static void PrintInfo (IWhatsMyAgeAgain item, ISayMyName item) {Console.WriteLine ("Name: {0}, age {1 } ", ItemGateName (), ItemGateage ()); } Static zero major () {c 1a = new c1 () {name = "tom", age = 2 9}; Console.ReadLine (); }}
after IWhatsMyAgeAgain for GetAge < / code> method returns integer but your class returns string , change this for: class C1: IWhatsMyAgeAgain, ISayMyName {public Integer age The name of the public string; Public string GetName () {return name; } Public int GetAge () {return age; }}
Comments
Post a Comment