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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek KumarPosted May 7, 2014, 10:49 AM
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.
Jignesh TrivediPosted May 7, 2014, 8:37 AM
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.
VulpesPosted May 7, 2014, 8:31 AM
class hai : hello
{
}