M
moondaddy
I'm new to c# and am wondering if its possible to access members of a nested
class. Can someone please advise? Thanks.
class Program
{
static void Main(string[] args)
{
try
{
Test1 obj = new Test1();
Console.WriteLine(obj.namex);
Console.WriteLine(obj.Test2.Test3.namexx); //this wont
compile. is there a correct way to do this?
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
public class Test1
{
public string namex = "xxxxxxxx";
public class Test2
{
public class Test3
{
public string namexx = "zzzzzzzzzz";
}
}
}
class. Can someone please advise? Thanks.
class Program
{
static void Main(string[] args)
{
try
{
Test1 obj = new Test1();
Console.WriteLine(obj.namex);
Console.WriteLine(obj.Test2.Test3.namexx); //this wont
compile. is there a correct way to do this?
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
public class Test1
{
public string namex = "xxxxxxxx";
public class Test2
{
public class Test3
{
public string namexx = "zzzzzzzzzz";
}
}
}