「C#」同じメソッドをオーバーロードするサンプル
使用例
using System;
namespace ProjectKm
{
class TestInfo
{
//メソッドtestFuncA
public string testFuncA(int x)
{
return x ;
}
//メソッドtestFuncA
public string testFuncA(int x, string y)
{
return x + y;
}
}
class CftDemo
{
static void Main()
{
TestInfo cftA = new TestInfo();
string resA = cftA.testFuncA(456);
Console.WriteLine(resA);
string resB = cftA.testFuncA(123, "test33");
Console.WriteLine(resB);
}
}
}
using System;
namespace ProjectKm
{
class TestInfo
{
//メソッドtestFuncA
public string testFuncA(int x)
{
return x ;
}
//メソッドtestFuncA
public string testFuncA(int x, string y)
{
return x + y;
}
}
class CftDemo
{
static void Main()
{
TestInfo cftA = new TestInfo();
string resA = cftA.testFuncA(456);
Console.WriteLine(resA);
string resB = cftA.testFuncA(123, "test33");
Console.WriteLine(resB);
}
}
}
using System; namespace ProjectKm { class TestInfo { //メソッドtestFuncA public string testFuncA(int x) { return x ; } //メソッドtestFuncA public string testFuncA(int x, string y) { return x + y; } } class CftDemo { static void Main() { TestInfo cftA = new TestInfo(); string resA = cftA.testFuncA(456); Console.WriteLine(resA); string resB = cftA.testFuncA(123, "test33"); Console.WriteLine(resB); } } }