G
garyusenet
I have 'cli via c# on order', and in the mean time am reading 'Pro C#
2005 and the .NET platform' (Andrew Troelson). I'm just reading about
the 'five types defined in the CTS'. Specifically Struct. Now Troelson
described the struct type as 'a lightweight class type having value
based semantics'.
Looking at his example I cant see any difference from a class here
other than it is defined with the struct keyword? what is the
difference between these two?
Also, Troelson speaks of the class type as having 'value based
semantics' what does that mean?
Thanks very much for your help.
Gary-
// A C# structure type.
struct Point
{
// Structures can contain fields.
public int xPos, yPos;
// Structures can contain parameterized constructors.
public Point(int x, int y)
{ xPos = x; yPos = y;}
// Structures may define methods.
public void Display()
{
Console.WriteLine("({0}, {1}", xPos, yPos);
}
}
2005 and the .NET platform' (Andrew Troelson). I'm just reading about
the 'five types defined in the CTS'. Specifically Struct. Now Troelson
described the struct type as 'a lightweight class type having value
based semantics'.
Looking at his example I cant see any difference from a class here
other than it is defined with the struct keyword? what is the
difference between these two?
Also, Troelson speaks of the class type as having 'value based
semantics' what does that mean?
Thanks very much for your help.
Gary-
// A C# structure type.
struct Point
{
// Structures can contain fields.
public int xPos, yPos;
// Structures can contain parameterized constructors.
public Point(int x, int y)
{ xPos = x; yPos = y;}
// Structures may define methods.
public void Display()
{
Console.WriteLine("({0}, {1}", xPos, yPos);
}
}