Question: I want to define a class inside a class.

example:

```
private class newClient
{
    public int ID { get; set; }
    public string Name{ get; set; }        

    private class ClientExtraData
    {
       public string ExtraField1 { get; set; }
       public string ExtraField2 { get; set; }
    }
}

```

now i want to access the ExtraField1 in such way:

```
newClient nclnt= new newClient();
string s=nclnt.ClientExtraData.ExtraField1;

```

Can this be done?

Answer: 
To Achieve the below, 

```
newClient nclnt= new newClient();
string s=nclnt.ClientExtraData.ExtraField1;

```

All you need to do is expose a property like this

```
private class NewClient
{
        public class NewClient() 
        {
            this.ClientExtraData = new ClientData();
        }
        public int ID { get; set; }
        public string Name{ get; set; }
        public ClientData ClientExtraData {get;set;}
}

```

where `ClientData` is a class in your assembly.
I usually do this kind of stuff like this:

```
//the two classes can live in the same code file, if you want.
private class ClientExtraDataClass
{
    public string ExtraField1 { get; set; }
   public string ExtraField2 { get; set; }
}
private class newClient
{
    public int ID { get; set; }
    public string Name{ get; set; }

    //you may want to make it a readonly property too, 
    // it depends on your needs.
    public ClientExtraDataClass ClientExtraData = new ClientExtraDataClass();
}

```