user34537
user34537

Reputation:

How to make a "typedef" involving a nested class?

I can do

using MyType = System.Collections.Generic.List<SomeClass.AClass>;

Now i only need MyType to be used within SomeClass. So i dont really need SomeClass to be public. However i can only do this outside of my namespace.

So how do i work this in such a way i can use MyType without making SomeClass and SomeClass.AClass public?

Upvotes: 0

Views: 273

Answers (1)

Jon
Jon

Reputation: 437376

I don't see what this could gain you apart from saving keystrokes. If you want to do this to keep the option of easily replacing the List with another type of collection, then you can change the static types of the variable holding the collection to an appropriate interface.

That said, if you must go this way for some reason, there is always this option:

// Just to be used as a typedef
class MyType : System.Collections.Generic.List<SomeClass.AClass>
{
}

You can do this inside SomeClass.

Upvotes: 1

Related Questions