45 lines
828 B
C#
45 lines
828 B
C#
internal class Program
|
|
{
|
|
// 구조체 정의
|
|
struct MyPoint
|
|
{
|
|
public int X;
|
|
public int Y;
|
|
|
|
public MyPoint(int x, int y)
|
|
{
|
|
this.X = x;
|
|
this.Y = y;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("({0}, {1})", X, Y);
|
|
}
|
|
}
|
|
|
|
sealed class MyPointC
|
|
{
|
|
public int X;
|
|
public int Y;
|
|
|
|
public MyPointC(int x, int y)
|
|
{
|
|
this.X = x;
|
|
this.Y = y;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("({0}, {1})", X, Y);
|
|
}
|
|
}
|
|
|
|
private static void Main(string[] args)
|
|
{
|
|
// 구조체 사용
|
|
MyPoint pt = new MyPoint(10, 12);
|
|
Console.WriteLine(pt.ToString());
|
|
|
|
}
|
|
} |