using System;
class SampleClass
{
public int sum(int n, int m)
{
return n + m;
}
public int sum(int n, int m, int l)
{
return n + m + l;
}
public int sum(ref int n)
{
return ++n;
}
public void sum(int n,out int m,out int l)
{
m=n+1;
l=m+1;
}
public void sum(string s1,string s2)
{
Console.WriteLine(s1+s2);
}
}
class MainClass
{
static void Main()
{
// SampleClassをインスタンス化
SampleClass sample = new SampleClass();
sample.sum("Sample","Class");
Console.WriteLine
("1+2={0}", sample.sum(1, 2));
Console.WriteLine
("1+2+3={0}", sample.sum(1, 2, 3));
int n = 1;
Console.WriteLine("n={0}", n);
sample.sum(ref n);
Console.WriteLine("n={0}", n);
int a, b;
sample.sum(1, out a, out b);
Console.WriteLine
("a={0} b={1}", a, b);
}
}
0 コメント:
コメントを投稿