I am trying to capitalize the first letter of the first name, middle name and the last name.
I am trying to use System.Globalization.TextInfo.ToTitleCase(newUser.Firstname) but i am getting an error in visual studio saying "An object reference is required for the non-static field, method or property". Help me with the solution for this:
public static UserAccount CreateUser(string firstName, string middleName, string lastName, string nameSuffix, int yearOfBirth, int? monthOfBirth, int? dayOfBirth, string email, string password, UserRole roles, bool tosAccepted = false)
{
var newUser = new UserAccount
{
CreationDate = DateTime.Now,
ActivationCode = Guid.NewGuid(),
FirstName = firstName,
MiddleName = middleName,
LastName = lastName,
NameSuffix = nameSuffix,
YearOfBirth = yearOfBirth,
MonthOfBirth = monthOfBirth,
DayOfBirth = dayOfBirth,
Email = email,
UserRoles = roles,
ToSAccepted = tosAccepted
};
string newUsers= System.Globalization.TextInfo.ToTitleCase(newUser.FirstName);
newUser.SetPassword(password);
return newUser;
}