3

Is there a possibility to declare an abbreviation for some types like DependencyPropertyChangedEventArgs so the lines don't get too long?

I have a method declared like this:

static void HtmlChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)

Now I was thinking of a way to declare an abbreviation for the EventArgs. I tried it with using:

using DPCEA = DependencyPropertyChangedEventArgs;

However, that doesn't work. I get the following exception:

The type or namespace name 'DependencyPropertyChangedEventArgs' could not be found.

I'd like to be able to declare my method like this:

static void HtmlChanged(DependencyObject depObj, DPCEA e)

Is there any possibility to achieve this?

diiN__________
  • 7,393
  • 6
  • 42
  • 69
  • When using `using` you need to use the full namespace: `using DPCEA = System.Windows.DependencyPropertyChangedEventArgs;` – haim770 Jun 21 '16 at 11:49

1 Answers1

2

In using statements, you need to give the full type name, including namespace:

using DPCEA = System.Windows.DependencyPropertyChangedEventArgs;

Note that you have to repeat this in every file, so it might get tiresome and a maintenance nightmare.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325