Skip to content

Instantly share code, notes, and snippets.

@yanickrochon yanickrochon/User.cs
Created Nov 28, 2013

Embed
What would you like to do?
Example my "issue" with C#'s naming convention. While most modern language have a "camel case" convention, C# uses an "upper camel case" (or "pascal case") convention. This cause problem when translating from, let say, JavaScript (JSON), or XML into C#.
public class User {
// composed class
public enum UserRole {
Guest = 0,
Subscriber = 1,
Supervisor = 2,
Editor = 3,
Publisher = 4,
Administrator = 5
}
public int Id { get; set }
public string Login { get; set; }
// ex: UserRole UserRole.... O_o ... see below...
public UserRole UserRole { get; set; }
}
public static class UserManagement {
public static ValidateAdminPrivilege(User user) {
return user.UserRole == User.UserRole.Administrator;
// ^ Instanc.Property
// ^ Class.Enum
// -> The only difference is the 'u' for the instance...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.