命名空间vs物理编码? [英] Namespaces vs physically coding?
问题描述
可能重复:
使用语句和命名空间路径? 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屋!