using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apps
{
class Test123
{
/// <summary>
/// Number of parameters should vary between the same method name(method overloading)
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public int Method1(int x, int y)
{
return 0;
}
/// <summary>
/// We can also implement different types of parameters.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
/// <returns></returns>
public string Method1(string x, int y, int z)
{
return "Hi";
}
}
class UnderstandingMethodOverloading
{
public static void Main()
{
Test123 obj = new Test123();
Console.WriteLine(obj.Method1(10, 11));
Console.WriteLine(obj.Method1("Hi", 11, 11));
}
}
}
No comments:
Post a Comment