访问命名空间及其类 [英] To access Namespace and its class

查看:118
本文介绍了访问命名空间及其类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,我需要您的帮助,因为我已经编写了代码(用C#语言编写)
:-公共课本(该课本在命名空间固定版内)
现在,我想从类Magazine中访问类Books(但是类Magazine在命名空间库中)
主席先生,我认为了解这种从一个名称空间访问另一个名称空间的类很重要.有可能这样做吗?如果可能的话如何?先生,您能帮我吗?

Dear sir, I need your help that I have written a code (in C#)
:- public class Books (that class Books is within the Namespace Stationary)
Now I want to access class Books from a class Magazine(However class Magazine is within the Namespace Library)
Sir, I think it is important to know such kind of accessing classes from One Namespace to another Namespace. Is there any possible to do so? If possible how? Can you help me sir.

推荐答案

检查类Books命名空间.您说您已经宣布图书为公开图书.因此可以从Magazine类访问它.只需检查类书籍的名称空间.然后,如果它不起作用,只需将您的代码发布在这里.
Check class Books namespace. you said that you have declare books as public. so it can be accessed from class Magazine. Just check the namespace of class books. and after that if it is not working just post your code here.


我认为您应该检查book类的访问修饰符.确保它是公开的.
其次,请确保将固定库"引用到库"项目(名称空间)中.

最后,您可以使用文具类的名称空间从杂志类访问书籍类.

谢谢:)
I think you should check the access modifier for book class.. make sure it is public first.

Secondly, make sure that Stationary library is referenced into Library project (name space).

Finally, you can access book class from magazine class using the name space of Stationary class.

Thanks :)


您的意思是像您如何从名称空间访问.NET类吗?
You mean like how you access the .NET classes from your namespace?


这篇关于访问命名空间及其类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆