我们如何在窗口表单中的一个名称空间中编写两个类 [英] how can we write two classes in one name space in window forms

查看:78
本文介绍了我们如何在窗口表单中的一个名称空间中编写两个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在窗口窗体中的一个名称空间中编写两个类。如果可能告诉我c#中的一些示例代码

is it posibble to write two classes in one name space in window forms .if possible tell me some example code in c#

推荐答案

是的,当然,总是。 Windows.Forms在这里完全无关紧要。允许一切不被禁止的东西。



这个问题没有多大意义,只是因为你可以提出数百万个问题,以便得到是/否答案,这是完全没有效率的。相反,你需要尝试看看它是否有效。如果失败,您可以阅读错误消息和文档。如果你不明白,那是唯一一个问一些问题的时间。



-SA
Yes, of course, always. "Windows.Forms" is totally irrelevant here. Everything which is not prohibited is allowed.

The question makes little sense, just because you can ask millions of questions like that in order just to get yes/no answer, which is utterly inefficient. Instead, all you need to try and see if it works. If it fails, you can read the error message and documentation. If you don't understand it, that's the only time to ask some question.

—SA


是:

Yes:
namespace MyNameSpace
    {
    public partial class MyFirstClass
        {
        ...
        }
    public partial class MySecondClass
        {
        ...
        }
    }

这两个类不必在同一个文件中。默认情况下,添加到项目的每个类都在同一个命名空间中,但您可以通过更改文件的命名空间行来更改此项。

The two classes do not have to be in the same file. By default, every class you add to a Project is in the same Namespace, but you can change this by altering the namespace line of the file.


这篇关于我们如何在窗口表单中的一个名称空间中编写两个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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