Majid Kamali

Majid Kamali

  • NA
  • 290
  • 256.2k

Create a class as property

Aug 22 2010 11:10 AM
Hi.
I have a class named 'MAIN'. within it there is a nested class named 'NESTED' and it is a private class.
in MAIN class, I declared an object of NESTED class.
How can I create a public property that represents that object.

Here's a sample code:
 public class MAIN
{
public MAIN()
{
nest = new NESTED();
}
NESTED nest;
class NESTED
{
}
public NESTED nested
{
get
{
return nest;
}
set
{
nest = value;
}
}
}

In this code, Compiler Creates error because NESTED class accessibility is private and nest object is public.
What Should I do?
Thanks.

Answers (2)