开发者

"No Overload Method for GetLine" Help (C#) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何学Python Closed 10 years ago.

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.
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜