using System;
struct Sample
{
public string name;
public int age;
public Sample(string s, int n)
{
name = s;
age = n;
}
}
class MainClass
{
static void Main()
{
// 既定のコンストラクタ
Sample sample1 = new Sample();
// 出力値:True
Console.WriteLine(sample1.name==null);
Console.WriteLine(sample1.age==0);
Sample sample2 = new Sample("Kamimura", 0);
Console.WriteLine("Name {0}", sample2.name);
Console.WriteLine("Age {0}", sample2.age);
}
}
0 コメント:
コメントを投稿