Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Overloading
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class ParentClass { public int ParentMethod(int a, int b) { Console.WriteLine(a+b); return a+b; } //public int ParentMethod(int a, int b) --> Error, already defines a member called 'ParentMethod' with the same parameter types and //{ // same return type //Console.WriteLine(a+b); //return a+b; //} //public string ParentMethod(int a, int b) --> Error, already defines a member called 'ParentMethod' with the same parameter types and //{ // same return type // string aval= a.ToString(); //string bval= b.ToString(); //Console.WriteLine(aval+bval); // return aval+bval; //} public int ParentMethod(int a,int b,int c) { Console.WriteLine(a+b+c); return a+b+c; } } public class ChildClass: ParentClass { public int ParentMethod(int a, int b, int c,int d) { Console.WriteLine(a+b+c+d); return a+b+c+d; } } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); ChildClass cc=new ChildClass(); cc.ParentMethod(1,2); cc.ParentMethod(1,2,3); cc.ParentMethod(1,2,3,4); ParentClass pc=cc; pc.ParentMethod(3,4); } } }
run
|
edit
|
history
|
help
0
Creating async methods in C# prior to version 5.0
Gestion de stock
Необязательные аргументы
Unity Character Controller Version 1
Events
datetime
OOP vs DOD
file Info and File Stream
Intuit // C# // listing_4.10 (for..)
Array Comparison