Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type renaming in C# with a renamed type

Tags:

c#

.net

using IdType = System.Guid;
using RowType = System.Tuple<System.Guid, object>

works. while

using IdType = System.Guid;
using RowType = System.Tuple<IdType, object>

does not compile.
The IdType declared at first row cannot be used with further using it seems.

Is there a way around this?

like image 422
LosManos Avatar asked Dec 10 '22 11:12

LosManos


1 Answers

This will work:

using IdType = System.Guid;
namespace x
{
    using RowType = System.Tuple<IdType, object>;
}

The reason being that type aliases only apply within declarations in the namespace within which they are contained.

like image 55
James Gaunt Avatar answered Dec 13 '22 00:12

James Gaunt