T
Taylor
I'm trying to understand inheritance. I'd like to make my own type of
IPAddress lets call it myIp.
The following gives me CS0029 error: Cannot implicitly convert type
'System.Net.IPAddress' to 'Inheritance_Testing.myIp'
Could you steer me in the right direction?
class myIp : System.Net.IPAddress
{
private IPAddress ip;
public myIp(long l) : base(l)
{
this.ip = new IPAddress(l);
}
[STAThread]
static void Main(string[] args)
{
myIp t = myIp.Parse("127.0.0.1");
byte[] bts = t.GetAddressBytes();
foreach(byte b in bts)
{
Console.WriteLine(b.ToString());
}
}
}
IPAddress lets call it myIp.
The following gives me CS0029 error: Cannot implicitly convert type
'System.Net.IPAddress' to 'Inheritance_Testing.myIp'
Could you steer me in the right direction?
class myIp : System.Net.IPAddress
{
private IPAddress ip;
public myIp(long l) : base(l)
{
this.ip = new IPAddress(l);
}
[STAThread]
static void Main(string[] args)
{
myIp t = myIp.Parse("127.0.0.1");
byte[] bts = t.GetAddressBytes();
foreach(byte b in bts)
{
Console.WriteLine(b.ToString());
}
}
}