C # - Default MessageBox.Show () signature

Is there a way to have a default MessageBox.Show () header? Let's say that I would like my application name to be called by the Message Box header and I don't want to keep typing MessageBox.Show (msg, ApplicationName). I just want to call MessageBox.Show (msg).

+2


source to share


4 answers


make a global function like this:

static class Global
{
    public static void ShowMyMessage(string msg)
    {
     MessageBox.Show(msg, ApplicationName)   
    }
}

      



now when you want to show a message, just write:

Global.ShowMyMessage("Message");

      

+7


source


No, but you can write a helper method that does what you want.



+2


source


I don't believe so. But why not just create a wrapper function that puts that signature by default in the MessageBox and they you just call the wrapper function.

+2


source


It is best to use a wrapper function, but you can inherit from the MessageBox control and find text from the active application window.

+1


source







All Articles