How to define a Method with no return in C# [closed]
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);
}
精彩评论