On Github y-tsutsu / reveal.js-LT_overload
static void DoSomething(char c) { Console.WriteLine(c); } static void DoSomething(string s) { Console.WriteLine(s); } static void DoSomething(char c, int n) { Console.WriteLine(new string(c, n)); }
class Program { static readonly Func<int, int> Something = x => x * 2; static int DoSomething(int n) { return n * 2; } static void Main(string[] args) { Console.WriteLine(Something(42)); Console.WriteLine(DoSomething(42)); } }
class Program { static readonly Func<int, int> Something = x => x * 2; static readonly Func<string, int> Something = x => int.Parse(x) * 2; static void Main(string[] args) { Console.WriteLine(Something(42)); Console.WriteLine(Something("42")); } }
Error'Something' の定義を既に含んでいます
class Program { static Func<char, string> Something(int n) { return c => new string(c, n); } static void Main(string[] args) { var hoge = Something(42); Console.WriteLine(hoge('A')); // 1行で書くと Console.WriteLine(Something(42)('A')); } }
class Program { static Func<char, string> Something(int n) { return c => new string(c, n); } static string Something(int n, char c) { return new string(c, n); } static void Main(string[] args) { Console.WriteLine(Something(42)('A')); Console.WriteLine(Something(42, 'A')); } }
class Program { static string DoSomething(int n, char c) { return new string(c, n); } static string DoSomething(int n, string s) { return new string(' ', n).Replace(" ", s); } static void Main(string[] args) { Console.WriteLine(DoSomething(42, 'A')); Console.WriteLine(DoSomething(23, "XYZ")); } }
class Program { static Func<char, string> Something(int n) { return c => new string(c, n); } static Func<string, string> Something(int n) { return s => new string(' ', n).Replace(" ", s); } static void Main(string[] args) { Console.WriteLine(Something(42)('A')); Console.WriteLine(Something(23)("XYZ")); } }
Error'Something' と呼ばれるメンバーを同じパラメーターの型で既に定義しています