Not sure how to explain this, so I'll try to give as much detail as possible. I'm making a Net Library and I need to give a section to my NetClient class, such as Headers in this example:
NetClient netClient = new NetClient("host", port);
netClient.Headers.Add("Name", "Value");
I would think this would work, but it doesn't (can't see the Headers class at all in an instance of NetClient class):
namespace NetLib
{
class NetClient
{
public string Host { get; }
public int Port { get; }
public NetClient(string host, int port)
{
this.Host = host;
this.Port = port;
}
class Headers
{
class Header
{
public string Name { get; }
public string Value { get; }
internal Header(string name, string value)
{
this.Name = name;
this.Value = value;
}
}
I solved my problem with the help of submitted answers, this is what my code looks like now:
public sealed class NetClient
{
public string Host { get; set; }
public int Port { get; set; }
public Headers Headers { get; private set; }
public NetClient(string host, int port)
{
this.Headers = new Headers();
this.Host = host;
this.Port = port;
}
}
public sealed class Headers
{
public class Header
{
public string Name { get; }
public string Value { get; }
internal Header(string name, string value)
{
this.Name = name;
this.Value = value;
}
}