ch02 StructTest
structは値タイプ、クラスは参照タイプです.
誠品服装英倫男装無条件返品
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StructTest
{ // point
public struct point
{
public int x;
public int y;
}
// Rectangle
public struct Rectangle
{
public point topleft;
public point topright;
public point bottomleft;
public point bottomright;
public bool used;
}
class Program
{
static void Main(string[] args)
{
// Rectangle
Rectangle rec, rc;
rec.topleft.x = 200;
rec.topleft.y = 200;
rec.topright.x = 300;
rec.topright.y = 200;
rec.bottomleft.x = 200;
rec.bottomleft.y = 300;
rec.bottomright.x = 300;
rec.bottomright.y = 300;
rec.used = true;
rc = rec;
Console.WriteLine("rc.topleft.x={0}", rc.topleft.x);
Console.WriteLine("rc.topleft.y={0}", rc.topleft.y);
Console.WriteLine("rc.topright.x={0}", rc.topright.x);
Console.WriteLine("rc.topright.y={0}", rc.topright.y);
Console.WriteLine("rc.bottomleft.x={0}", rc.bottomleft.x);
Console.WriteLine("rc.bottomleft.y={0}", rc.bottomleft.y);
Console.WriteLine("rc.bottomright.x={0}", rc.bottomright.x);
Console.WriteLine("rc.bottomright.y={0}", rc.bottomright.y);
Console.WriteLine("rc.used={0}", rc.used);
Console.ReadKey();
}
}
}
誠品服装英倫男装無条件返品