C# parameters in interface -


class test {     public test(string name, string age) {     } }  interface itest         ????????  class example: itest {     public example(/* ... */) {     } } 

so should use in interface use same parameters in example in test?

what want do:

  • i have 3 classes: a, b , c.

  • i want c inherit both a , b.

but c# doesn't let ... want use interface.

edit classes are:

  • student(name, age, studies)
  • teacher(name, age, classes)
  • working student/teacher(name, age, studied/classes, payment)

so want use methods in working class other classes.

interfaces used contract classes inherit it. means public methods/properties want interface expose, must exposed in inherited class.

in case above, don't have public methods/properties exposed in interface. let me show example.

interface itest {    void addperson(string name, string age); }  interface iperson {     string returnpersonsage(string name); }  /// must expose addperson method /// must expose returnpersonbyage method class example : itest, iperson {    dictionary<string, string> people = new dictionary<string, string>();     void addperson(string name, string age)    {       people.add(name, age);    }     string returnpersonsage(string name)    {       return people[name];    } } 

i hope helps, feel free ask more questions can narrow down question.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -