0

Here is sample code as mentioned below

class Program
{
    static void Main(string[] args)
    {
        Program prgm = new Program();
        string sprgm = prgm.OverloadedMethod(null);
        Console.ReadKey();
    }

    private string OverloadedMethod(object arg)
    {
        return "object as parameter";
    }

    private string OverloadedMethod(string arg)
    {
        return "string as parameter ";
    }
}

when i pass null as parameter. it is the acceptable value for both string overloaded menthod and object overloaded method but why string overloaded method is called?

FCin
  • 3,804
  • 4
  • 20
  • 49
Aravind Goud
  • 120
  • 2
  • 17

0 Answers0