Can .NET role name have spaces in it


Can a Role name have spaces in it? At the moment I always name my Roles without such as 'NewsEditor'. Can it be 'News Editor' without errors? Also, is there a best practice for formatting the name of a Role?

Thanks for your time with this.
Who is Participating?
Role name can have spaces but should not have commas.

System.ArgumentException will be thrown if the role name is an empty string or contains a comma or longer than 256 characters.

System.ArgumentNullException will be thrown if role name is a null reference.

Role names are not case-sensitive.

Using spaces in role names may give you a meaningful description about the role. But you need to be careful when you use the role names in your code if it has spaces. Because if the role is defined with spaces in the database and if you missed the spaces somewhere in your code, then it will lead to some issues. My personal suggestion would be to avoid spaces.

Rolenames may not be empty or contain commas. Anything else shorter than 255 characters should be fine.
Maheshwar RSoftware DeveloperCommented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.