开发者

How to define a Method with no return in 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. Closed 11 years ago.

I'm a beginner in C#. I want to define a Method that has an input. And the input will be shown in an a开发者_StackOverflow社区lert box with this Method. In other words, the duty of this method is receiving a variable. Every where that I call this method, the message will be alerted. I want to know how to define and How to call.


your return type should be "void"

for example:

public void showMsg(string text)
{
    MessageBox.Show(text);
}

you would call your method like this:

showMsg("I can has alert?");


All you have to do is declare the return type as void:

public void MyMethod(string input)
{
    MessageBox.Show(input);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜