Search code examples
c#abbreviation

Abbreviation for EventArgs


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?


Solution

  • 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.