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());
}
}
} 12 1694
try change private IPAddress ip;
to private System.Net.IPAddress ip;
and the same for new IPAddress(l);
--
Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message news:#e**************@TK2MSFTNGP12.phx.gbl... 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()); }
} }
Thanks for the suggestion Michael, but the same error occurs when I supply
the full name for IPAddress. Here is what I have now, but same error.
class myIp : System.Net.IPAddress
{
private System.Net.IPAddress ip;
public myIp(long l) : base(l)
{
this.ip = new System.Net.IPAddress(l);
}
[STAThread]
static void Main(string[] args)
{
myIp t = myIp.Parse("127.0.0.1"); // ---->error here
byte[] bts = t.GetAddressBytes();
foreach(byte b in bts)
{
Console.WriteLine(b.ToString());
}
}
}
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl... try change private IPAddress ip; to private System.Net.IPAddress ip;
and the same for new IPAddress(l);
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message
news:#e**************@TK2MSFTNGP12.phx.gbl... 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()); }
} }
Ah, now I see the problem. The Parse function still returns an IPAddress, not a myIp. You need to add this code to your myIp class.
public static new myIp Parse(string ipString)
{
myIp x = new myIp(0);
x.ip = System.Net.IPAddress.Parse(ipString);
return x;
}
--
Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message news:Oz*************@tk2msftngp13.phx.gbl... Thanks for the suggestion Michael, but the same error occurs when I supply the full name for IPAddress. Here is what I have now, but same error.
class myIp : System.Net.IPAddress { private System.Net.IPAddress ip;
public myIp(long l) : base(l) { this.ip = new System.Net.IPAddress(l); }
[STAThread] static void Main(string[] args) { myIp t = myIp.Parse("127.0.0.1"); // ---->error here byte[] bts = t.GetAddressBytes(); foreach(byte b in bts) { Console.WriteLine(b.ToString()); }
} }
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:e2**************@TK2MSFTNGP11.phx.gbl... try change private IPAddress ip; to private System.Net.IPAddress ip;
and the same for new IPAddress(l);
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message news:#e**************@TK2MSFTNGP12.phx.gbl... 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()); }
} }
Hi Michael,
You've have made me a very happy camper! Thank you, Thank you! Finally
I've entered the OO world, this was my first inheritance. I'm much richer
now! I will study it further. You can tell I've spent some time staring at
this one by how incredibly pleased I am!
I really appreciate your sticking with me on this one!
Thanks Michael,
Taylor
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:uK**************@TK2MSFTNGP11.phx.gbl... Ah, now I see the problem. The Parse function still returns an IPAddress,
not a myIp. You need to add this code to your myIp class. public static new myIp Parse(string ipString) { myIp x = new myIp(0); x.ip = System.Net.IPAddress.Parse(ipString); return x; }
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl... Thanks for the suggestion Michael, but the same error occurs when I
supply the full name for IPAddress. Here is what I have now, but same error.
class myIp : System.Net.IPAddress { private System.Net.IPAddress ip;
public myIp(long l) : base(l) { this.ip = new System.Net.IPAddress(l); }
[STAThread] static void Main(string[] args) { myIp t = myIp.Parse("127.0.0.1"); // ---->error here byte[] bts = t.GetAddressBytes(); foreach(byte b in bts) { Console.WriteLine(b.ToString()); }
} }
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:e2**************@TK2MSFTNGP11.phx.gbl... try change > private IPAddress ip; to > private System.Net.IPAddress ip;
and the same for new IPAddress(l);
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message news:#e**************@TK2MSFTNGP12.phx.gbl... > 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()); > } > > } > } > > > >
Sure, you can get this to work, but, in this situation, more importantly
why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning that
to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent the same
IP.
(did that make any sense?)
Good luck!
Brian W
"Taylor" <ta****@u.washington.edu> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl... Hi Michael,
You've have made me a very happy camper! Thank you, Thank you! Finally I've entered the OO world, this was my first inheritance. I'm much richer now! I will study it further. You can tell I've spent some time staring
at this one by how incredibly pleased I am!
I really appreciate your sticking with me on this one!
Thanks Michael, Taylor
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... Ah, now I see the problem. The Parse function still returns an
IPAddress, not a myIp. You need to add this code to your myIp class. public static new myIp Parse(string ipString) { myIp x = new myIp(0); x.ip = System.Net.IPAddress.Parse(ipString); return x; }
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message news:Oz*************@tk2msftngp13.phx.gbl... Thanks for the suggestion Michael, but the same error occurs when I supply the full name for IPAddress. Here is what I have now, but same error.
class myIp : System.Net.IPAddress { private System.Net.IPAddress ip;
public myIp(long l) : base(l) { this.ip = new System.Net.IPAddress(l); }
[STAThread] static void Main(string[] args) { myIp t = myIp.Parse("127.0.0.1"); // ---->error here byte[] bts = t.GetAddressBytes(); foreach(byte b in bts) { Console.WriteLine(b.ToString()); }
} }
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:e2**************@TK2MSFTNGP11.phx.gbl... > try change > > private IPAddress ip; > to > > private System.Net.IPAddress ip; > > and the same for new IPAddress(l); > > -- > Michael Culley > > > "Taylor" <ta****@u.washington.edu> wrote in message news:#e**************@TK2MSFTNGP12.phx.gbl... > > 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()); > > } > > > > } > > } > > > > > > > > > >
Good point. Hmmmm.... I'm trying to get this right... This shouldn't be so
hard, but I'm just not getting the right combination. This next attempt
doesn't work either because the an implicit conversion from a myIp to a
System.Net.IPAddress is not possible. I've tried to make an explicit
conversion, but I can't seem to get it right.
namespace test
{
using System;
using System.Net;
class myIp : System.Net.IPAddress
{
private System.Net.IPAddress ip;
public myIp(long l)
: base(l)
{
}
}
class TestMyIP
{
[STAThread]
static void Main(string[] args)
{
myIp ip = myIp.Parse("127.0.0.1");
Console.WriteLine(ip.ToString());
}
}
}
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:e6*************@tk2msftngp13.phx.gbl... Sure, you can get this to work, but, in this situation, more importantly why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning that to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent the
same IP.
(did that make any sense?)
Good luck! Brian W "Taylor" <ta****@u.washington.edu> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl... Hi Michael,
You've have made me a very happy camper! Thank you, Thank you! Finally I've entered the OO world, this was my first inheritance. I'm much
richer now! I will study it further. You can tell I've spent some time
staring at this one by how incredibly pleased I am!
I really appreciate your sticking with me on this one!
Thanks Michael, Taylor
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... Ah, now I see the problem. The Parse function still returns an IPAddress, not a myIp. You need to add this code to your myIp class. public static new myIp Parse(string ipString) { myIp x = new myIp(0); x.ip = System.Net.IPAddress.Parse(ipString); return x; }
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl... > Thanks for the suggestion Michael, but the same error occurs when I supply > the full name for IPAddress. Here is what I have now, but same
error. > > class myIp : System.Net.IPAddress > { > private System.Net.IPAddress ip; > > public myIp(long l) : base(l) > { > this.ip = new System.Net.IPAddress(l); > } > > > [STAThread] > static void Main(string[] args) > { > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > byte[] bts = t.GetAddressBytes(); > foreach(byte b in bts) > { > Console.WriteLine(b.ToString()); > } > > } > } > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > news:e2**************@TK2MSFTNGP11.phx.gbl... > > try change > > > private IPAddress ip; > > to > > > private System.Net.IPAddress ip; > > > > and the same for new IPAddress(l); > > > > -- > > Michael Culley > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > 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()); > > > } > > > > > > } > > > } > > > > > > > > > > > > > > > > > >
I'm thinking that my problem is similar to this one: http://www.dotnet247.com/247referenc...25/126903.aspx
<quote>
The problem with all-static classes is that when you
derive from them, you can't override or 'new' the methods.
If you cast DerivedClass to BaseClass and call
MethodOne(), it'll call BaseClass.MethodOne() instead of
DerivedClass.MethodOne(), even though it's really
a DerivedClass to begin with.
</quote>
Going on this advice I'm reduced to only being able to create a BaseClass
IPAddress object, right? Going off advice in the above url I find that I
can do this:
IPAddress ip = myIp.Parse("127.0.0.1");
but does that mean that I'm reduced to never bing able to create an instance
of myIp? I can only then call static methods?
Need I go searching on how to create an abstract factory class similar to
what they're talking about in the above url?
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:e6*************@tk2msftngp13.phx.gbl... Sure, you can get this to work, but, in this situation, more importantly why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning that to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent the
same IP.
(did that make any sense?)
Good luck! Brian W "Taylor" <ta****@u.washington.edu> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl... Hi Michael,
You've have made me a very happy camper! Thank you, Thank you! Finally I've entered the OO world, this was my first inheritance. I'm much
richer now! I will study it further. You can tell I've spent some time
staring at this one by how incredibly pleased I am!
I really appreciate your sticking with me on this one!
Thanks Michael, Taylor
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... Ah, now I see the problem. The Parse function still returns an IPAddress, not a myIp. You need to add this code to your myIp class. public static new myIp Parse(string ipString) { myIp x = new myIp(0); x.ip = System.Net.IPAddress.Parse(ipString); return x; }
-- Michael Culley
"Taylor" <ta****@u.washington.edu> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl... > Thanks for the suggestion Michael, but the same error occurs when I supply > the full name for IPAddress. Here is what I have now, but same
error. > > class myIp : System.Net.IPAddress > { > private System.Net.IPAddress ip; > > public myIp(long l) : base(l) > { > this.ip = new System.Net.IPAddress(l); > } > > > [STAThread] > static void Main(string[] args) > { > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > byte[] bts = t.GetAddressBytes(); > foreach(byte b in bts) > { > Console.WriteLine(b.ToString()); > } > > } > } > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > news:e2**************@TK2MSFTNGP11.phx.gbl... > > try change > > > private IPAddress ip; > > to > > > private System.Net.IPAddress ip; > > > > and the same for new IPAddress(l); > > > > -- > > Michael Culley > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > 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()); > > > } > > > > > > } > > > } > > > > > > > > > > > > > > > > > >
Well, firstly, IPAddress isn't a static class. Parse is a static method and
this
Perhaps you need to pick up a book on OO design and/or programming. Reading
such a book is certainly better, not to mention more productive, than just
jumping in head first.
In addition, you may want to try something simpler.
In this case if you really want to derive from IPAddress the following
should be what you are looking for. Note that myIp has not member of type
IPAddress. Also note the cast from IPAddress to myIp.
In this specific example there really is not reason for this constructor.
the default constructor would suffice.
namespace ConsoleApplication1
{
class myIp : System.Net.IPAddress
{
public myIp(long l) : base(l)
{
}
}
/// <summary>
/// Summary description for Class1.
/// </summary>
///
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Just cast it.
myIp ip = (myIp)myIp.Parse("127.0.0.1");
//
// TODO: Add code to start application here
//
}
}
}
"Taylor" <ta****@u.washington.edu> wrote in message
news:O5*************@TK2MSFTNGP11.phx.gbl... I'm thinking that my problem is similar to this one: http://www.dotnet247.com/247referenc...25/126903.aspx
<quote> The problem with all-static classes is that when you derive from them, you can't override or 'new' the methods.
If you cast DerivedClass to BaseClass and call MethodOne(), it'll call BaseClass.MethodOne() instead of DerivedClass.MethodOne(), even though it's really a DerivedClass to begin with. </quote>
Going on this advice I'm reduced to only being able to create a BaseClass IPAddress object, right? Going off advice in the above url I find that I can do this:
IPAddress ip = myIp.Parse("127.0.0.1");
but does that mean that I'm reduced to never bing able to create an
instance of myIp? I can only then call static methods?
Need I go searching on how to create an abstract factory class similar to what they're talking about in the above url?
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:e6*************@tk2msftngp13.phx.gbl... Sure, you can get this to work, but, in this situation, more importantly why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning
that to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent the same IP.
(did that make any sense?)
Good luck! Brian W "Taylor" <ta****@u.washington.edu> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl... Hi Michael,
You've have made me a very happy camper! Thank you, Thank you!
Finally I've entered the OO world, this was my first inheritance. I'm much richer now! I will study it further. You can tell I've spent some time staring at this one by how incredibly pleased I am!
I really appreciate your sticking with me on this one!
Thanks Michael, Taylor
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... > Ah, now I see the problem. The Parse function still returns an IPAddress, not a myIp. You need to add this code to your myIp class. > > public static new myIp Parse(string ipString) > { > myIp x = new myIp(0); > x.ip = System.Net.IPAddress.Parse(ipString); > return x; > } > > -- > Michael Culley > > > "Taylor" <ta****@u.washington.edu> wrote in message news:Oz*************@tk2msftngp13.phx.gbl... > > Thanks for the suggestion Michael, but the same error occurs when
I supply > > the full name for IPAddress. Here is what I have now, but same error. > > > > class myIp : System.Net.IPAddress > > { > > private System.Net.IPAddress ip; > > > > public myIp(long l) : base(l) > > { > > this.ip = new System.Net.IPAddress(l); > > } > > > > > > [STAThread] > > static void Main(string[] args) > > { > > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > > byte[] bts = t.GetAddressBytes(); > > foreach(byte b in bts) > > { > > Console.WriteLine(b.ToString()); > > } > > > > } > > } > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > > news:e2**************@TK2MSFTNGP11.phx.gbl... > > > try change > > > > private IPAddress ip; > > > to > > > > private System.Net.IPAddress ip; > > > > > > and the same for new IPAddress(l); > > > > > > -- > > > Michael Culley > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > > 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()); > > > > } > > > > > > > > } > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > >
Hi Brian,
I tried your code, but it produced an InvalidCastException.
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:eD*************@TK2MSFTNGP10.phx.gbl... Well, firstly, IPAddress isn't a static class. Parse is a static method
and this
Perhaps you need to pick up a book on OO design and/or programming.
Reading such a book is certainly better, not to mention more productive, than just jumping in head first.
In addition, you may want to try something simpler.
In this case if you really want to derive from IPAddress the following should be what you are looking for. Note that myIp has not member of type IPAddress. Also note the cast from IPAddress to myIp.
In this specific example there really is not reason for this constructor. the default constructor would suffice.
namespace ConsoleApplication1 {
class myIp : System.Net.IPAddress {
public myIp(long l) : base(l) { } }
/// <summary> /// Summary description for Class1. /// </summary> ///
class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) {
// Just cast it. myIp ip = (myIp)myIp.Parse("127.0.0.1");
// // TODO: Add code to start application here // } } } "Taylor" <ta****@u.washington.edu> wrote in message news:O5*************@TK2MSFTNGP11.phx.gbl... I'm thinking that my problem is similar to this one: http://www.dotnet247.com/247referenc...25/126903.aspx
<quote> The problem with all-static classes is that when you derive from them, you can't override or 'new' the methods.
If you cast DerivedClass to BaseClass and call MethodOne(), it'll call BaseClass.MethodOne() instead of DerivedClass.MethodOne(), even though it's really a DerivedClass to begin with. </quote>
Going on this advice I'm reduced to only being able to create a
BaseClass IPAddress object, right? Going off advice in the above url I find that
I can do this:
IPAddress ip = myIp.Parse("127.0.0.1");
but does that mean that I'm reduced to never bing able to create an instance of myIp? I can only then call static methods?
Need I go searching on how to create an abstract factory class similar
to what they're talking about in the above url?
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:e6*************@tk2msftngp13.phx.gbl... Sure, you can get this to work, but, in this situation, more
importantly why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning that to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent
the same IP.
(did that make any sense?)
Good luck! Brian W "Taylor" <ta****@u.washington.edu> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl... > Hi Michael, > > You've have made me a very happy camper! Thank you, Thank you! Finally > I've entered the OO world, this was my first inheritance. I'm much richer > now! I will study it further. You can tell I've spent some time staring at > this one by how incredibly pleased I am! > > I really appreciate your sticking with me on this one! > > Thanks Michael, > Taylor > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > news:uK**************@TK2MSFTNGP11.phx.gbl... > > Ah, now I see the problem. The Parse function still returns an IPAddress, > not a myIp. You need to add this code to your myIp class. > > > > public static new myIp Parse(string ipString) > > { > > myIp x = new myIp(0); > > x.ip = System.Net.IPAddress.Parse(ipString); > > return x; > > } > > > > -- > > Michael Culley > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > news:Oz*************@tk2msftngp13.phx.gbl... > > > Thanks for the suggestion Michael, but the same error occurs
when I > supply > > > the full name for IPAddress. Here is what I have now, but same error. > > > > > > class myIp : System.Net.IPAddress > > > { > > > private System.Net.IPAddress ip; > > > > > > public myIp(long l) : base(l) > > > { > > > this.ip = new System.Net.IPAddress(l); > > > } > > > > > > > > > [STAThread] > > > static void Main(string[] args) > > > { > > > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > > > byte[] bts = t.GetAddressBytes(); > > > foreach(byte b in bts) > > > { > > > Console.WriteLine(b.ToString()); > > > } > > > > > > } > > > } > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in
message > > > news:e2**************@TK2MSFTNGP11.phx.gbl... > > > > try change > > > > > private IPAddress ip; > > > > to > > > > > private System.Net.IPAddress ip; > > > > > > > > and the same for new IPAddress(l); > > > > > > > > -- > > > > Michael Culley > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > > > 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()); > > > > > } > > > > > > > > > > } > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
Brian,
Here is the pattern you're suggesting
Given
class B{}
class D:B{}
class C{
public static void Main(string[] args)
{
D d = (D)(new B());
}
}
which is a widening conversion, which I thought to be invalid. Certainly
B b = (D)(new B())
is valid cause base class references can refer to derived class instances
otherwise we wouldn't have polymorphism, right?
Well, I guess my problem is that I don't understand how to make the derived
class's "new" operator return a derived class instance. Error code CS0029
suggests that we do something like
public static implicit operator new(...
but that doesn't seem to work either.
Hmmmm...
I like Brian's reasoning, and he has a point as to how using Micahel's
solution we create too many IPAddress's, but I can't seem to pull these two
ideas together...
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:eD*************@TK2MSFTNGP10.phx.gbl... Well, firstly, IPAddress isn't a static class. Parse is a static method
and this
Perhaps you need to pick up a book on OO design and/or programming.
Reading such a book is certainly better, not to mention more productive, than just jumping in head first.
In addition, you may want to try something simpler.
In this case if you really want to derive from IPAddress the following should be what you are looking for. Note that myIp has not member of type IPAddress. Also note the cast from IPAddress to myIp.
In this specific example there really is not reason for this constructor. the default constructor would suffice.
namespace ConsoleApplication1 {
class myIp : System.Net.IPAddress {
public myIp(long l) : base(l) { } }
/// <summary> /// Summary description for Class1. /// </summary> ///
class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) {
// Just cast it. myIp ip = (myIp)myIp.Parse("127.0.0.1");
// // TODO: Add code to start application here // } } } "Taylor" <ta****@u.washington.edu> wrote in message news:O5*************@TK2MSFTNGP11.phx.gbl... I'm thinking that my problem is similar to this one: http://www.dotnet247.com/247referenc...25/126903.aspx
<quote> The problem with all-static classes is that when you derive from them, you can't override or 'new' the methods.
If you cast DerivedClass to BaseClass and call MethodOne(), it'll call BaseClass.MethodOne() instead of DerivedClass.MethodOne(), even though it's really a DerivedClass to begin with. </quote>
Going on this advice I'm reduced to only being able to create a
BaseClass IPAddress object, right? Going off advice in the above url I find that
I can do this:
IPAddress ip = myIp.Parse("127.0.0.1");
but does that mean that I'm reduced to never bing able to create an instance of myIp? I can only then call static methods?
Need I go searching on how to create an abstract factory class similar
to what they're talking about in the above url?
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:e6*************@tk2msftngp13.phx.gbl... Sure, you can get this to work, but, in this situation, more
importantly why?
You have myIp that derive from IPAddress.
myIp has a field (member) of type IPAddress
you are constructing an instance of myIp by passing l
you are then creating and instance of IPAddress using l and assigning that to the member ip.
since myIp _IS_ a IPAddress you now have 2 instances that represent
the same IP.
(did that make any sense?)
Good luck! Brian W "Taylor" <ta****@u.washington.edu> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl... > Hi Michael, > > You've have made me a very happy camper! Thank you, Thank you! Finally > I've entered the OO world, this was my first inheritance. I'm much richer > now! I will study it further. You can tell I've spent some time staring at > this one by how incredibly pleased I am! > > I really appreciate your sticking with me on this one! > > Thanks Michael, > Taylor > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > news:uK**************@TK2MSFTNGP11.phx.gbl... > > Ah, now I see the problem. The Parse function still returns an IPAddress, > not a myIp. You need to add this code to your myIp class. > > > > public static new myIp Parse(string ipString) > > { > > myIp x = new myIp(0); > > x.ip = System.Net.IPAddress.Parse(ipString); > > return x; > > } > > > > -- > > Michael Culley > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > news:Oz*************@tk2msftngp13.phx.gbl... > > > Thanks for the suggestion Michael, but the same error occurs
when I > supply > > > the full name for IPAddress. Here is what I have now, but same error. > > > > > > class myIp : System.Net.IPAddress > > > { > > > private System.Net.IPAddress ip; > > > > > > public myIp(long l) : base(l) > > > { > > > this.ip = new System.Net.IPAddress(l); > > > } > > > > > > > > > [STAThread] > > > static void Main(string[] args) > > > { > > > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > > > byte[] bts = t.GetAddressBytes(); > > > foreach(byte b in bts) > > > { > > > Console.WriteLine(b.ToString()); > > > } > > > > > > } > > > } > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in
message > > > news:e2**************@TK2MSFTNGP11.phx.gbl... > > > > try change > > > > > private IPAddress ip; > > > > to > > > > > private System.Net.IPAddress ip; > > > > > > > > and the same for new IPAddress(l); > > > > > > > > -- > > > > Michael Culley > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > > > 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()); > > > > > } > > > > > > > > > > } > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
Right you are, Taylor, My Bad!. That's what I get for writing-compiling and
not running. ;-) You can't cast it that way.
You will have to write your own static Parse method to using the new syntax
as Michael suggested to return myIp. But the rest of the class and example
is still valid.
I would still incourage you to get your hands on some books on the subject
of OO design/programming
Good luck
Brian W
"Taylor" <ta****@u.washington.edu> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl... Hi Brian,
I tried your code, but it produced an InvalidCastException.
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Well, firstly, IPAddress isn't a static class. Parse is a static method and this
Perhaps you need to pick up a book on OO design and/or programming. Reading such a book is certainly better, not to mention more productive, than
just jumping in head first.
In addition, you may want to try something simpler.
In this case if you really want to derive from IPAddress the following should be what you are looking for. Note that myIp has not member of
type IPAddress. Also note the cast from IPAddress to myIp.
In this specific example there really is not reason for this
constructor. the default constructor would suffice.
namespace ConsoleApplication1 {
class myIp : System.Net.IPAddress {
public myIp(long l) : base(l) { } }
/// <summary> /// Summary description for Class1. /// </summary> ///
class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) {
// Just cast it. myIp ip = (myIp)myIp.Parse("127.0.0.1");
// // TODO: Add code to start application here // } } } "Taylor" <ta****@u.washington.edu> wrote in message news:O5*************@TK2MSFTNGP11.phx.gbl... I'm thinking that my problem is similar to this one: http://www.dotnet247.com/247referenc...25/126903.aspx
<quote> The problem with all-static classes is that when you derive from them, you can't override or 'new' the methods.
If you cast DerivedClass to BaseClass and call MethodOne(), it'll call BaseClass.MethodOne() instead of DerivedClass.MethodOne(), even though it's really a DerivedClass to begin with. </quote>
Going on this advice I'm reduced to only being able to create a BaseClass IPAddress object, right? Going off advice in the above url I find
that I can do this:
IPAddress ip = myIp.Parse("127.0.0.1");
but does that mean that I'm reduced to never bing able to create an instance of myIp? I can only then call static methods?
Need I go searching on how to create an abstract factory class similar to what they're talking about in the above url?
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:e6*************@tk2msftngp13.phx.gbl... > Sure, you can get this to work, but, in this situation, more importantly > why? > > You have myIp that derive from IPAddress. > > myIp has a field (member) of type IPAddress > > you are constructing an instance of myIp by passing l > > you are then creating and instance of IPAddress using l and
assigning that > to the member ip. > > since myIp _IS_ a IPAddress you now have 2 instances that represent
the same > IP. > > (did that make any sense?) > > > Good luck! > Brian W > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > news:eB**************@TK2MSFTNGP09.phx.gbl... > > Hi Michael, > > > > You've have made me a very happy camper! Thank you, Thank you! Finally > > I've entered the OO world, this was my first inheritance. I'm much richer > > now! I will study it further. You can tell I've spent some time staring > at > > this one by how incredibly pleased I am! > > > > I really appreciate your sticking with me on this one! > > > > Thanks Michael, > > Taylor > > > > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > > news:uK**************@TK2MSFTNGP11.phx.gbl... > > > Ah, now I see the problem. The Parse function still returns an > IPAddress, > > not a myIp. You need to add this code to your myIp class. > > > > > > public static new myIp Parse(string ipString) > > > { > > > myIp x = new myIp(0); > > > x.ip = System.Net.IPAddress.Parse(ipString); > > > return x; > > > } > > > > > > -- > > > Michael Culley > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > news:Oz*************@tk2msftngp13.phx.gbl... > > > > Thanks for the suggestion Michael, but the same error occurs when I > > supply > > > > the full name for IPAddress. Here is what I have now, but
same error. > > > > > > > > class myIp : System.Net.IPAddress > > > > { > > > > private System.Net.IPAddress ip; > > > > > > > > public myIp(long l) : base(l) > > > > { > > > > this.ip = new System.Net.IPAddress(l); > > > > } > > > > > > > > > > > > [STAThread] > > > > static void Main(string[] args) > > > > { > > > > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > > > > byte[] bts = t.GetAddressBytes(); > > > > foreach(byte b in bts) > > > > { > > > > Console.WriteLine(b.ToString()); > > > > } > > > > > > > > } > > > > } > > > > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in
message > > > > news:e2**************@TK2MSFTNGP11.phx.gbl... > > > > > try change > > > > > > private IPAddress ip; > > > > > to > > > > > > private System.Net.IPAddress ip; > > > > > > > > > > and the same for new IPAddress(l); > > > > > > > > > > -- > > > > > Michael Culley > > > > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > > > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > > > > 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()); > > > > > > } > > > > > > > > > > > > } > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:ef**************@tk2msftngp13.phx.gbl... Right you are, Taylor, My Bad!. That's what I get for writing-compiling
and not running. ;-) You can't cast it that way.
You will have to write your own static Parse method to using the new
syntax as Michael suggested to return myIp. But the rest of the class and example is still valid.
I would still incourage you to get your hands on some books on the subject of OO design/programming
Good luck Brian W
"Taylor" <ta****@u.washington.edu> wrote in message news:uv**************@TK2MSFTNGP12.phx.gbl... Hi Brian,
I tried your code, but it produced an InvalidCastException.
Taylor
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Well, firstly, IPAddress isn't a static class. Parse is a static
method and this
Perhaps you need to pick up a book on OO design and/or programming. Reading such a book is certainly better, not to mention more productive, than just jumping in head first.
In addition, you may want to try something simpler.
In this case if you really want to derive from IPAddress the following should be what you are looking for. Note that myIp has not member of type IPAddress. Also note the cast from IPAddress to myIp.
In this specific example there really is not reason for this constructor. the default constructor would suffice.
namespace ConsoleApplication1 {
class myIp : System.Net.IPAddress {
public myIp(long l) : base(l) { } }
/// <summary> /// Summary description for Class1. /// </summary> ///
class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) {
// Just cast it. myIp ip = (myIp)myIp.Parse("127.0.0.1");
// // TODO: Add code to start application here // } } } "Taylor" <ta****@u.washington.edu> wrote in message news:O5*************@TK2MSFTNGP11.phx.gbl... > I'm thinking that my problem is similar to this one: > http://www.dotnet247.com/247referenc...25/126903.aspx > > > <quote> > The problem with all-static classes is that when you > derive from them, you can't override or 'new' the methods. > > If you cast DerivedClass to BaseClass and call > MethodOne(), it'll call BaseClass.MethodOne() instead of > DerivedClass.MethodOne(), even though it's really > a DerivedClass to begin with. > </quote> > > Going on this advice I'm reduced to only being able to create a BaseClass > IPAddress object, right? Going off advice in the above url I find that I > can do this: > > IPAddress ip = myIp.Parse("127.0.0.1"); > > but does that mean that I'm reduced to never bing able to create an instance > of myIp? I can only then call static methods? > > Need I go searching on how to create an abstract factory class
similar to > what they're talking about in the above url? > > Taylor > > > > > "Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message > news:e6*************@tk2msftngp13.phx.gbl... > > Sure, you can get this to work, but, in this situation, more importantly > > why? > > > > You have myIp that derive from IPAddress. > > > > myIp has a field (member) of type IPAddress > > > > you are constructing an instance of myIp by passing l > > > > you are then creating and instance of IPAddress using l and assigning that > > to the member ip. > > > > since myIp _IS_ a IPAddress you now have 2 instances that
represent the > same > > IP. > > > > (did that make any sense?) > > > > > > Good luck! > > Brian W > > > > > > > > > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > news:eB**************@TK2MSFTNGP09.phx.gbl... > > > Hi Michael, > > > > > > You've have made me a very happy camper! Thank you, Thank you! Finally > > > I've entered the OO world, this was my first inheritance. I'm
much > richer > > > now! I will study it further. You can tell I've spent some
time > staring > > at > > > this one by how incredibly pleased I am! > > > > > > I really appreciate your sticking with me on this one! > > > > > > Thanks Michael, > > > Taylor > > > > > > > > > > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in
message > > > news:uK**************@TK2MSFTNGP11.phx.gbl... > > > > Ah, now I see the problem. The Parse function still returns an > > IPAddress, > > > not a myIp. You need to add this code to your myIp class. > > > > > > > > public static new myIp Parse(string ipString) > > > > { > > > > myIp x = new myIp(0); > > > > x.ip = System.Net.IPAddress.Parse(ipString); > > > > return x; > > > > } > > > > > > > > -- > > > > Michael Culley > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > > news:Oz*************@tk2msftngp13.phx.gbl... > > > > > Thanks for the suggestion Michael, but the same error occurs when I > > > supply > > > > > the full name for IPAddress. Here is what I have now, but same > error. > > > > > > > > > > class myIp : System.Net.IPAddress > > > > > { > > > > > private System.Net.IPAddress ip; > > > > > > > > > > public myIp(long l) : base(l) > > > > > { > > > > > this.ip = new System.Net.IPAddress(l); > > > > > } > > > > > > > > > > > > > > > [STAThread] > > > > > static void Main(string[] args) > > > > > { > > > > > myIp t = myIp.Parse("127.0.0.1"); // ---->error here > > > > > byte[] bts = t.GetAddressBytes(); > > > > > foreach(byte b in bts) > > > > > { > > > > > Console.WriteLine(b.ToString()); > > > > > } > > > > > > > > > > } > > > > > } > > > > > > > > > > > > > > > "Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message > > > > > news:e2**************@TK2MSFTNGP11.phx.gbl... > > > > > > try change > > > > > > > private IPAddress ip; > > > > > > to > > > > > > > private System.Net.IPAddress ip; > > > > > > > > > > > > and the same for new IPAddress(l); > > > > > > > > > > > > -- > > > > > > Michael Culley > > > > > > > > > > > > > > > > > > "Taylor" <ta****@u.washington.edu> wrote in message > > > > > news:#e**************@TK2MSFTNGP12.phx.gbl... > > > > > > > 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()); > > > > > > > } > > > > > > > > > > > > > > } > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: KK |
last post by:
Windows Forms Inheritance, Incomplete?
I was playing around with Windows Forms
and found out this Forms Inheritance feature.
The moment I saw that, I felt this can be
used effectively if the...
|
by: KK |
last post by:
** Posting it here cause after couple of days no body responded.**
I was playing around with Windows Forms
and found out this Forms Inheritance feature.
The moment I saw that, I felt this can...
|
by: Dave Theese |
last post by:
Hello all,
The example below demonstrates proper conformance to the C++ standard.
However, I'm having a hard time getting my brain around which language rules
make this proper...
The error...
|
by: __PPS__ |
last post by:
Hello everybody, today I had another quiz question
"if class X is privately derived from base class Y what is the scope of
the public, protected, private members of Y will be in class X"
By...
|
by: Matthew Louden |
last post by:
I want to know why C# doesnt support multiple inheritance? But why we can
inherit multiple interfaces instead? I know this is the rule, but I dont
understand why. Can anyone give me some concrete...
|
by: Ben Blank |
last post by:
I'm writing a family of classes which all inherit most of their methods and
code (including constructors) from a single base class. When attempting to
instance one of the derived classes using...
|
by: VR |
last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some
WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages,
my MasterPage does not have a form tag itself...
|
by: Noah Roberts |
last post by:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
|
by: RSH |
last post by:
I have a simple question regarding inheritance in a web form.
I have a DropDownList in an aspx form. It is called DropDownList1
I have a class that will be overriding the render event so I...
|
by: RSH |
last post by:
Hi,
I am working on some general OOP constructs and I was wondering if I could
get some guidance.
I have an instance where I have a Base Abstract Class, and 4 Derived
classes. I now need to...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |