Hey,
I have 2 classes
class hello
{
}
class hai
{
}
I need to create an object of the class in the following format
hello hl=new hai();
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
Abhishek KumarRank #510 · 4.8K reputationPosted May 7, 2014, 6:49 AM EDT
for below clases
class hello
{
}
class hai
{
}
class hai should act as base class for derived Hello
class hai :Hello
{
}
then hello hl=new hai(); will be work.
VulpesRank #55 · 29.2K reputationPosted May 7, 2014, 4:31 AM EDT
class hai : hello
{
}
Jignesh TrivediRank #16 · 50.3K reputationPosted May 7, 2014, 4:37 AM EDT
you can also create property of that class and initialize in constructor.
public class hello
{
public hai other {get;set;}
public hello()
{
other = new hai();
}
}
public class hai
{
}
hope this will help you.