"No Overload Method for GetLine" Help (C#) [closed]
I have tried something like: "GetLine(fileName,line)" no luck
Code:
static void Main(string[] args)
{
GetLine();
}
string GetLine(string fileName, int line)
{
......
}
You are calling the GetLine declared non-static from within a static function.
Either mark the GetLine declaration as static, or create an instance of the class containing both the functions.
it should be a static method if you want to call directly like that.
private static string GetLine(string fileName, int line)
If you want to overload the method GetLine
it must be marked with the virtual
indicator.
virtual string GetLine(string fileNmae, int line)
{
//Code for method goes here
}
Update :
As Mario Vernari suggested you will need to make the method static.
If you want to call the method like this GetLine()
then you will need to create a new overloaded method for GetLine.
static string GetLine()
{
return "Some string message"; //Return a string.
}
精彩评论