ModS
ModS

Reputation: 836

Creating a variable for a namespace

Is it possible to shorten a namespace via a variable? Example; Instead of typing "System.Windows.MessageBox.Show("");" i am hoping to be able to make a variable to the location "system.windows" so i can do Variable.MessageBox("");

Upvotes: 0

Views: 57

Answers (2)

Rahul
Rahul

Reputation: 77866

You can assign the namesspace variable like

using M = System.Windows;

M.MessageBox.Show("");

(OR)

Define a method of your own and call it like

public void Show(string s)
{
  MessageBox.Show(s);
}

Now you can call it like

Show("something");

Upvotes: 2

Inisheer
Inisheer

Reputation: 20794

Try:

using SW = System.Windows;

SW.MessageBox.Show("");

Upvotes: 4

Related Questions