0

你选择哪一个以及为什么:

public class User
{
    public long UserID { get; set; }
}

public class User
{
    public long UserId { get; set; }
}

也可以作为参数:

public void DoSomething(long userId) { }
public void DoSomething(long userID) { }
4

2 回答 2

3

约定使得选择UserIduserId分别非常清楚(强调我的):

标识符中可以使用的两个缩写是 ID 和 OK。在 Pascal 大小写标识符中,它们应该显示为 Id 和 Ok。如果用作驼峰式标识符中的第一个单词,它们应该分别显示为 id 和 ok。

于 2012-01-11T05:14:46.443 回答
0

对于 Id,它是 Identifier 的缩写,而不是首字母缩写词;在第一个字母之后使其小写是有意义的。

于 2012-01-11T05:16:14.633 回答