Exemplo n.º 1
0
        //[TestMethod]
        public bool ShouldCallOverloadWithoutDefaultParam()
        {
            var actual = MethodOverloading.DefaultParamExample(10);

            return(actual == "Foo(int x)");
            //Assert.AreEqual(actual, "Foo(int x)");
        }
Exemplo n.º 2
0
        //[TestMethod]
        public bool ShouldCallFooWithReturnTypeGuid()
        {
            var actual = MethodOverloading.Foo(10D);

            return(actual is Guid);
            //Assert.IsInstanceOfType(actual, typeof(Guid));
        }
Exemplo n.º 3
0
        //[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));
        }
Exemplo n.º 4
0
        //[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);
        }
Exemplo n.º 5
0
    public static void Main(String[] args)
    {
        int radius = 5, lenght = 5, breath = 7;
        MethodOverloading obj = new MethodOverloading();

        obj.area(radius);
        obj.area(lenght, breath);
    }
Exemplo n.º 6
0
    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);
    }
Exemplo n.º 7
0
 public static void Main()
 {
     MethodOverloading.add(10, 20);
     MethodOverloading.add(10, 20, 30);
 }