Ch02 ConstrunctTest
コンストラクション関数は特殊なメンバー関数です.コンストラクション関数は、タイプ名と同じで、戻り値がないことが要求されます.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConstructTest
{
class Program
{
public struct point
{
public int x;
public int y;
public point(int x,int y)/構造関数の定義
{
this.x = x;//メンバーの割当て#メンバーノワリアテ#
this.y = y;
}
}
static void Main(string[] args)
{
point P1 = new point();
point P2 = new point(32, 45);
Console.WriteLine("P1.x={0}", P1.x);
Console.WriteLine("P1.y={0}", P1.y);
Console.WriteLine("P2.x={0}", P2.x);
Console.WriteLine("P2.y={0}", P2.y);
Console.ReadKey();
}
}
}
誠品服装英倫男装無条件返品
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConstructTest
{
class Program
{
public struct point
{
public int x;
public int y;
public point(int x,int y)/構造関数の定義
{
this.x = x;//メンバーの割当て#メンバーノワリアテ#
this.y = y;
}
}
static void Main(string[] args)
{
point P1 = new point();
point P2 = new point(32, 45);
Console.WriteLine("P1.x={0}", P1.x);
Console.WriteLine("P1.y={0}", P1.y);
Console.WriteLine("P2.x={0}", P2.x);
Console.WriteLine("P2.y={0}", P2.y);
Console.ReadKey();
}
}
}
誠品服装英倫男装無条件返品