“o”是什么意思?意思是变量前缀?
在奥康?规则是什么?
using(SqlConnection oCn = new SqlConnection(
"Server=(local);Database=Pubs;User ID=TestUser1;Password=foo1;")) {
oCn.Open();
...
}
我在本文 http://msdn.microsoft.com/ 中发现了这种命名类型en-us/magazine/cc163799.aspx
in oCn? What is the rule?
using(SqlConnection oCn = new SqlConnection(
"Server=(local);Database=Pubs;User ID=TestUser1;Password=foo1;")) {
oCn.Open();
...
}
I found that type of naming in this article http://msdn.microsoft.com/en-us/magazine/cc163799.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
一种完全过时的方式来表示“Cn”是一个 *o* 对象。
An entirely obsolete way of saying that "Cn" is an *o*bject.
我担心它是对象的一些匈牙利方言符号的剩余部分。
在 C# 和 .NET 中,我认为这毫无用处。
编辑 顺便说一句,我认为包含类型和/矿石范围信息的匈牙利表示法在 C# 中毫无用处。 我确实喜欢 Apps 匈牙利表示法
I am afraid that it is a remainder of some hungarian dialect notation for an object.
In C# and .NET I consider this useless.
EDIT By the way I consider Hungarian notation containing type and/ore scope information useless in C#. I do like Apps Hungarian notation
在这种情况下,“o”表示对象。这是使用匈牙利表示法的“系统”变体的尝试。
匈牙利语有两种类型:系统和应用。系统使用前缀来标识存储的数据类型。例如,iCounter 中的“i”表示该变量是整数。
匈牙利应用程序采取了完全不同的方法,并指定前缀应表明数据的用途。例如,rwPosition 中的“rw”表示行。
Windows api 使用 Systems 匈牙利语。这导致大量其他程序员也使用它。不幸的是,当对 api 进行更改时,即使实际数据类型发生更改,它们也会保留旧的变量名称。这导致了对于给定 API 函数的参数应该传递什么数据类型的大量混乱。尤其是各种把手周围。
在 .Net 编码指南中,MS 明确指出不应使用匈牙利语。事实是,他们正在谈论“系统”匈牙利语;我100%同意。另一方面,“应用程序”匈牙利语有很多用途,因为您描述的是数据,而不是类型。
最后只需删除“o”即可。它没有给程序添加任何内容。
哦,如果想阅读有趣的内容,请查看 Joel 对此的看法:http://www.joelonsoftware。 com/articles/Wrong.html
In this case, "o" means object. It's an attempt at using the "systems" variation of hungarian notation.
There are two types of hungarian: Systems and Apps. Systems uses a prefix to identify the type of data stored. For example, the "i" in iCounter would indicate that the variable was an integer.
Apps hungarian took a completely different approach and specifies that the prefix should indicate the purpose of the data. For example, the "rw" in rwPosition would mean row.
The windows api used Systems hungarian. This led to a large number of other programmers also using it. The unfortunate aspect is that when changes were made to the api, they kept the old variable names even when the actual data type changed. This led to large amounts of confusion as to what data type a parameter to a given API function should be passed. Especially around various handles.
In the .Net coding guidelines, MS explicitly states that hungarian shouldn't be used. The reality is that they are talking about "Systems" hungarian; which I 100% agree with. "Apps" hungarian on the other hand has a ton of uses as you are describing the data, not the type.
At the end of the day just remove the "o". It adds nothing to the program.
Oh, and for interesting reading, check out Joel's take on this at: http://www.joelonsoftware.com/articles/Wrong.html
它可能意味着
object
就像某些复杂类型一样,与命名字符串strMyString
和整数iMyInt
等相同(荒谬的)约定不太相符。It probably means
object
like in some complex type that does not fit well with the same (ridiculous) convention that names stringsstrMyString
and intsiMyInt
etc.这个“规则”直接来自如何编写不可维护的代码:
This "rule" comes directly from How To Write Unmaintainable Code:
o 代表对象,
这是一个不太有用的约定,其中变量的类型包含在名称中,因此字符串是 strWhatever。有时我什至看到obj,即objCn
o is for object,
it's a, not very usefull, convention where by the type of the variable was incuded in the name, so a string was strWhatever. sometimes i even saw obj, i.e. objCn
正如 @Humberto 所建议的,开发人员似乎使用 匈牙利表示法。
As @Humberto suggested, appears to be the developer using Hungarian Notation.
十年前,当我开始担任程序员时,我工作的公司正在使用类似的命名约定。我不记得约定名称是什么,但我记得所有对象实例都有“o”前缀,代表对象。
When I started working as a programmer 10 years ago, the compagny I worked for was using a similar naming convention. I can't remember what is the convention name but I do remember that all the object instances had the "o" prefix, standing for Object.