Possible Duplicate:
How to Capitalize names using C#
How can i retrieve values from database tables in First letter capital format?
My LINQ Query is like this,
DBEntities Context = new DBEntities ();
var UserNameEntity = (from a in Context.UserInformation
where a.UserId == UserId
select a).First();
string UserName = UserNameEntity.FirstName + " " + UserNameEntity.LastName;
return UserName;
I am getting user name : bhargav soni
but i want this should be like Bhargav Soni
How can i do that?
On your
FirstNameandLastNameproperties, use the indexer to retrieve the first character, and call theSubstring()method to retrieve the rest of the string.This assumes that both properties are at least two characters in length.
You can also do this entirely in LINQ:
Obviously, using String.Format instead of concatenation may or may not improve readability.