Policy Alias - What would it be? [duplicate]

0

Good afternoon guys,

I've been studying C #, I've come to see about the using directive, and in the C # documentation it says it has 3 uses, one of 3 usage items says it's meant to create an alias for a namespace or a type, but what would it be an alias directive and what is its usefulness? I researched and did not find out about.

    
asked by anonymous 04.12.2018 / 18:34

1 answer

0

It serves to avoid ambiguity. Imagine the following situation:

using System.Windows.Forms;  
using System.Windows.Input;

In these two namespaces there are classes in common. How would the compiler know which class you want? To resolve this and still use using you can create a nickname ( alias ):

using Input = System.Windows.Input; 

So, you could access, for example: Input.ModifierKeys not generating any ambiguity since it knows that Input refers to System.Windows.Input .

Some also believe that this is good practice, this I can not answer correctly.

  

This response was based on Zv_oDD's response to link ( SOen)

    
04.12.2018 / 18:40