如何调用从一个项目的类在另一个项目? [英] How to call classes from one Project in another Project?

查看:189
本文介绍了如何调用从一个项目的类在另一个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起了令人难以置信的愚蠢的问题,但即时通讯新的为C#。我只是无法弄清楚如何在另一个项目中使用类从一个项目。

Excuse the incredibly silly question but im new to C# . I just can’t figure out how to use classes from one Project in another Project.

可以说,我想一个字符串从PROJECT1到Project2的和有Project2的打印字符串说。

Lets say I want to take a string from Project1 to Project2 and have Project2 print said string .

我引用Project2中从PROJECT1的添加引用菜单,然后我加上使用Project2的,然后我写这篇文章来试图从ClassA的,在Project2的呼叫打印。

I reference Project2 from Project1 with the "add reference" menu , then I add "using Project2" and then I write this to trying and call "print" from "ClassA" in "Project2".

        Project2.ClassA Classa = new Project2.ClassA();
        Console.WriteLine(Classa.print);

但我得到的是错误信息。

but all i get are Error messages .

让任何人都可以请给一步的正是为什么我需要做一步的解释?

so can anyone please give a step by step explanation of EXACTLY why I need to do ?

推荐答案

当你从Project2的引用类是很可能在不同的命名空间。

When you reference the Class from Project2 it is probably in a different namespace.

添加命名空间中的类的顶部,你要使用的(在using语句),或者跟你的光标移到Project2.Class,让Visual Studio中为你做它: - )

Add the namespace in the top of your class where you are going to use is (the using statements) or, go with your cursor over the Project2.Class and let Visual Studio do it for you :-)

这篇关于如何调用从一个项目的类在另一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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