C#.cs文件名和类名需要匹配? [英] C# .cs file name and class name need to be matched?

查看:714
本文介绍了C#.cs文件名和类名需要匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中的文件名必须是在Java的文件中定义的公共类的名称。是否C#有类似的要求?我可以有一个A.cs文件,该文件只定义了内部A B公共类?谢谢,

In Java the file name must be the public class name defined in that java file. Does C# has similar requirement? can I have a A.cs file which only defines a public Class B inside? thanks,

推荐答案

没有,有没有类似的规定。

No, there is no similar requirement.

是的,你可以做到这一点。

Yes, you can do this.

然而,它被认为是不好的做法。

It is considered bad practice, however.

微软了StyleCop将发出警告如果你这样做,但一切将编译罚款。

Microsoft StyleCop will warn you if you do this, but everything will compile fine.

这篇关于C#.cs文件名和类名需要匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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