is there really no way in c# of shortening lengthy code like
Dictionary<my.very.long.type, my.other.long.type> myVar;
//code that repetitevely uses those classes
with something like
using acronym = my.very.long.type {
using acronym2 = my.other.long.type {
Dictionary<acronym , my.other.long.type> myVar;
//code that repetitively uses those classes
}
}
without using a file-wide alias? (using statements at the beginning of the file)
for a verbose language it seems like a must-have feature,
it would widely improve readability on the sections where the focus must be on the operation sequence rather than the types.
My searches have only found no as answer, but i refuse to believe it.
-EDIT- i'll include here some explanation i gave as comments as why i'm looking for this feature:
I like to be explicit and avoid using statements whenever possible. Still, for the sake of readability i'd like to "group them" at the beginning of the interested method or code-block.
Also, a public property should have an explicit understandable name, while the class methods implementations do not, and can use an acronym.
Sure i could define the property as a getter of a private acronym, but that's more code and more runtime overhead for something a compiler could expand for me.
..What i come from is the (javascript) let keyword. A local scoped reference, that could also "hold a class type".
As a compiled language C# should be able to avoid declaring a variable at all and just locally alias the name.
I don't remember having this problem in C++ either, maybe cuz it had pointers but it's been a while.