Tuesday, August 7, 2012

does method signature include return type in C sharp (c#)

does method signature include return type in C sharp (c#)

I would say  BIG  NO


I read a lot of blogs and finally i have decieded to test by self and i just make some simple code

protected int sum(int a, int b)
    {
        return a + b;
    }

    protected float sum(int a, int b)
    {
        return a + b;
    }


when i run this its throws error

already defines a member called 'sum' with the same parameter types

but if i change the parameter type then its runs OK

so final result is method signature not  include return type. and a method can be not overloaded just by changing its return type .



No comments:

Post a Comment

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...