i work on csharp issue but i don't know how to solve it
i have two classes A AND B
how to instaniate it as below
A a =new A();
A B =new B();
i work on csharp issue but i don't know how to solve it
i have two classes A AND B
how to instaniate it as below
A a =new A();
A B =new B();
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Apr 24, 2022, 3:12 AM EDT
Uttam KumarRank #1,076 · 1.8K reputationPosted Apr 24, 2022, 11:49 AM EDT
You can achieve it by implementing inheritance
Class A { //… } Class B : A { //… }Program { Main() { A obj1 = new A(); A obj2 = new B(); } }You can do this in couple of ways
1. By defining class A as abstract
2. By defining an interface
3. By defining a normal class
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Apr 24, 2022, 6:44 AM EDT