问:添加一个项目 [英] Q: adding a project

查看:64
本文介绍了问:添加一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hiya


我希望有人可以帮我解决这个相对简单的初学者问题:


我用C#创建了一个Windows应用程序。我还创建了一个项目,

,其中包括一个类。我已将项目添加到主应用程序但是

我似乎无法在主应用程序中创建该类的实例。

类名为MyFirstClass,名称空间为MyFirstClass。我需要采取哪些步骤才能在主窗口中创建类的实例

应用程序?


谢谢提前


Geoff

Hiya

I hope somebody can help me with this relatively simple beginner question:

I have created a windows Application in C#. I have also created a project,
which includes a class. I have added the project to the main application but
I can''t seem to create an instance of the class in the main application. The
class is called MyFirstClass, with namespace MyFirstClass. What steps do I
need to take to create an instance of the class within the main windows
application?

Thanks in advance

Geoff

推荐答案

您可以更改类的命名空间以与命名空间相对应

您的其他项目,因此两个程序集都成为一个名称空间。

然后,如果您使用myClass classOfMine = new myClass();它应该有效。


Geoff Jones写道:
You can change the namespace of your class to correspond with the namespace
of your other project so both assemblies become of one namespace.
Then, if you use myClass classOfMine = new myClass(); it should work.

"Geoff Jones" wrote:
Hiya

我希望有人可以帮我解决这个相对简单的初学者问题:

我创建了一个Windows应用程序在C#中。我还创建了一个项目,其中包括一个类。我已将项目添加到主应用程序但是我似乎无法在主应用程序中创建该类的实例。
类名为MyFirstClass,名称空间为MyFirstClass。我需要采取哪些步骤在主窗口
应用程序中创建类的实例?

提前致谢

Geoff
Hiya

I hope somebody can help me with this relatively simple beginner question:

I have created a windows Application in C#. I have also created a project,
which includes a class. I have added the project to the main application but
I can''t seem to create an instance of the class in the main application. The
class is called MyFirstClass, with namespace MyFirstClass. What steps do I
need to take to create an instance of the class within the main windows
application?

Thanks in advance

Geoff



确保两个文件中的命名空间都匹配。如果没有,那么您将不得不使用完全限定的名称




当您说我已将项目添加到主应用程序时我会假设你

的意思是我已将课程添加到主应用程序中。


如果他们是两个不同的项目那么你''我需要添加一个

的引用到另一个。


尝试

MyFirstClass.MyFirstClass instance = new MyFirstClass.MyFirstClass ();


- 约翰


杰夫琼斯< no ******** @ email.com>写道:
Make sure your namespaces in both files match up. If not then you will have to
use the fully qualified name.

When you say "I have added the project to the main application" I''ll assume you
meant "I have added the class to the main application".

If they are two different projects then you''ll need to add a reference from one
to the other.

Try
MyFirstClass.MyFirstClass instance = new MyFirstClass.MyFirstClass();

- john

Geoff Jones <no********@email.com> wrote:
Hiya

我希望有人可以帮我解决这个相对简单的初学者问题:

我在C#中创建了一个Windows应用程序。我还创建了一个项目,其中包括一个类。我已将项目添加到主应用程序但是我似乎无法在主应用程序中创建该类的实例。
类名为MyFirstClass,名称空间为MyFirstClass。我需要采取哪些步骤在主窗口
应用程序中创建类的实例?

提前致谢

Geoff
Hiya

I hope somebody can help me with this relatively simple beginner question:

I have created a windows Application in C#. I have also created a project,
which includes a class. I have added the project to the main application but
I can''t seem to create an instance of the class in the main application. The
class is called MyFirstClass, with namespace MyFirstClass. What steps do I
need to take to create an instance of the class within the main windows
application?

Thanks in advance

Geoff






我收到消息:


;预期





Geoff


" Vincent" <六***** @ discussions.microsoft.com>在消息中写道

news:64 ********************************** @ microsof t.com ...
I get the message:

; expected

?

Geoff

"Vincent" <Vi*****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
您可以更改类的名称空间以与其他项目的
名称空间相对应,这样两个程序集就成为一个名称空间。
然后,如果你使用myClass classOfMine = new myClass();它应该工作。

杰夫琼斯写道:
You can change the namespace of your class to correspond with the
namespace
of your other project so both assemblies become of one namespace.
Then, if you use myClass classOfMine = new myClass(); it should work.

"Geoff Jones" wrote:
Hiya

我希望有人可以帮助我这个相对简单的初学者
问题:

我有用C#创建了一个windows应用程序。我还创建了一个
项目,其中包括一个类。我已将项目添加到主应用程序
但是我似乎无法在主应用程序中创建类的实例。

类称为MyFirstClass,使用命名空间MyFirstClass。在主窗口
应用程序中需要采取哪些步骤才能创建类的实例?

提前致谢
Geoff
Hiya

I hope somebody can help me with this relatively simple beginner
question:

I have created a windows Application in C#. I have also created a
project,
which includes a class. I have added the project to the main application
but
I can''t seem to create an instance of the class in the main application.
The
class is called MyFirstClass, with namespace MyFirstClass. What steps do
I
need to take to create an instance of the class within the main windows
application?

Thanks in advance

Geoff



这篇关于问:添加一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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