Reputation: 56371
i.e. I have
namespace newProject{
public partial class Default_Animal {
protected int Amount = 5;
.....
}
.....
}
I have the default (hundreds) of properties and fields. I want to use it in second class like, to extend it :
using Dog = newProject.Default_Animal; //<--- this is example to show What i want to achieve
namespace newProject{
public partial class Dog : WildAnimal_X {
Print(Amount); //<--- doesn't seem to work
}
}
Upvotes: 1
Views: 779
Reputation: 156968
No, you can't alias the name of a class in its declaration. You also can't define the other part of the partial class in another namespace: the namespace, class name and parent type should all match.
Allowing this is not useful in any way. It opens up for confusion, as in this example. Dog
should be deriving from Animal
, and it should not be a partial class
with Animal
.
This is what you should have:
public class Dog : Animal /* drop Default_ */
{
}
Upvotes: 5