i’m new to c# .Net. in my solution, two namespaces cannot see each other.
I have project A which has partial class c1 and some methods in it.
Project B with a different namespace also has a partial class c1, some methods with same name of which in project A and some other methods.
I have added the reference in project A that reference to project B, have the using namespace B included in project A classes.
But still in A, i can’t use what’s in class c1 from B, i can only see the method of class c1 from A itself. i want to use methods of c1 from both projects in A.
Can anybody help me with this please? i’m using .Net framework 4
B is presumably a full class in the other namespace, but only defined as a partial class in a particular file. You can’t, as @tzerb mentions, have two of the same partial class in two different namespaces – by virtue of the fact that the namespaces are different, the class names themselves (fully qualified) are different.
If all you need is to use the methods from class B in class A (and perhaps override them), you can either use inheritance:
Or containment:
Use inheritance if
Ais aB, use containment otherwise.