开发者

Accessing internal member from outside

开发者 https://www.devze.com 2023-03-11 22:05 出处:网络
In SolutionA (Namespace name), I am calling a a memeber (functionA()) of internal class (ClassA )from another class (Engine)and this class through interface (IClassA).

In SolutionA (Namespace name), I am calling a a memeber (functionA()) of internal class (ClassA )from another class (Engine)and this class through interface (IClassA).

IClassA declares this function Engine Calls this function and using another method (smame method name in this case).

So if i want to call this internal member in another solution.

So in Solution B

I can do this :

using SolutionA;


IClassA iA;

iA = new Engine();

iA.fuctionA();

I guess it should give functionA when i do a [.] after iA , but intellisense is not giving ..whats wrong here?

Why i am not getting the functionA in SolutionB?

More info about my architechure:

//IClassA.cs
namespace namespaceA
{
internal class ClassA
{
    public string FunctionA(){}
}
}

//Engine.cs

namespace namespaceA
{
public class Engine() : IClassA()
{
    public IClassA.FunctionA(){}
}
}

// IClassA.cs
namespace namespaceA
{
public interface IClassA()
{
    string FunctionA(string data);
}
}

//ClassB.cs

namespace namespaceB
{
using  namespaceA开发者_如何转开发;

internal class Classb
{
    IClassA engine = new namespaceA.Engine();

    engine.FunctionA();  //here i am unable to get fuuction
}
}


Does the IClassA interface declare the function? My guess is that it doesn't. Given that the compile-time class of iA is IClassA, the compiler (and Intellisense) will only let you use members of IClassA.


It is highly unlikely that this is your problem, but I'll mention it because it is another problem that could cause your symptoms. If functionA has the [EditorBrowsable(EditorBrowsableState.Never)] attribute, it will not show up in Intellisense when you are in a different assembly. Though in that situation, ignoring Intellisense and using functionA would still allow the program to compile.

0

精彩评论

暂无评论...
验证码 换一张
取 消