Using the directive to define nested types

I am trying to use the type directive usingin a functional manner to make the code more readable. Say my example.cs file looks like this:

using A = System.Tuple<int, int>;
using B = List<A>;

I get an error message:

CS0246 Unable to find type name or namespace 'A' (are you missing the using directive or assembly references?)

Can I define nested types with usingor is this not possible?

+4
source share
1 answer

# docs.microsoft.com , , , - alias":

A using_alias_directive ( alias) .

use_alias_directive :

using_alias_directive
    : 'using' identifier '=' namespace_or_type_name ';'
    ;

, -, "namespace_or_type_name", "using_alias_directive". , ( ):

, using_alias_directives, , namespace_or_type_name, using_alias_directive, use_alias_directive _ . , _____________ ,

, .

+4

Source: https://habr.com/ru/post/1684880/


All Articles