//[TestMethod] public bool ShouldCallOverloadWithoutDefaultParam() { var actual = MethodOverloading.DefaultParamExample(10); return(actual == "Foo(int x)"); //Assert.AreEqual(actual, "Foo(int x)"); }
//[TestMethod] public bool ShouldCallFooWithReturnTypeGuid() { var actual = MethodOverloading.Foo(10D); return(actual is Guid); //Assert.IsInstanceOfType(actual, typeof(Guid)); }
//[TestMethod] // This shows that the compiler will choose the best argument conversion since return type of a method // is not considered to be part of a method's signature. // // Note: that compiler chooses an overload before it checks whether return type will cause an error // public bool ShouldCallFooWithReturnTypeString() { var actual = MethodOverloading.Foo(10); return(actual is string); //Assert.IsInstanceOfType(actual, typeof(string)); }
//[TestMethod] public bool ShouldAddNumbersPassingThreeNamedArguments() { var expected = 5 + 6 + 1; var actual = MethodOverloading.NamedArgumentExample(z: 1, y: 6, x: 5); return(actual == expected); //Assert.AreEqual(actual, expected); }
public static void Main(String[] args) { int radius = 5, lenght = 5, breath = 7; MethodOverloading obj = new MethodOverloading(); obj.area(radius); obj.area(lenght, breath); }
public static void Main() { MethodOverloading mol = new MethodOverloading(); mol.Add(10, 20, 30); mol.Add(40, 50, 50.5F); int sum = 0; mol.Add(60, 70, sum); }
public static void Main() { MethodOverloading.add(10, 20); MethodOverloading.add(10, 20, 30); }