命名空间vs物理编码? [英] Namespaces vs physically coding?

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

问题描述


可能重复:

使用语句和命名空间路径? C#


我只想知道将命名空间包含在



因此:

 

code>使用System.Windows;

  System.Windows.MessageBox.Show(); 

将命名空间加载整个库还是仅使用所需的数据?


解决方案

您需要区分命名空间和组件。它们是非常不同的东西。



只使用指令谈论名称空间引用 MessageBox 的两种方式将会产生完全相同的代码。使用任何产生最可读代码的代码 - 通常使用使用指令和短名称。


Possible Duplicate:
Using Statements vs Namespace path? C#

I just want to know what the difference between including the namespace at the top of a C# class vs actually defining it in the program code.

So:

using System.Windows;

Or

System.Windows.MessageBox.Show();

Would having the namespace load the whole library or will only the needed data be used?

Sorry if it may seem confusing.

解决方案

You need to distinguish between namespaces and assemblies. They're very different things.

using directives only talk about namespaces - and the two ways of referring to MessageBox will produce exactly the same code. Use whichever produces the most readable code - which is usually to use using directives and short names.

这篇关于命名空间vs物理编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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