// 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);
}
}
CTS Enumeration Types
Enumerations are handy programming constructs that allow you to group name/value pairs. For
example, assume you are creating a video-game application that allows the player to select one of
three character categories (Wizard, Fighter, or Thief ). Rather than keeping track of raw numerical
values to represent each possibility, you could build a custom enumeration using the enum keyword:
Do'stlaringiz bilan baham: |