Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6872251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:54:14+00:00 2026-05-27T03:54:14+00:00

Possible Duplicate: How to Capitalize names using C# How can i retrieve values from

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:54:15+00:00Added an answer on May 27, 2026 at 3:54 am

    On your FirstName and LastName properties, use the indexer to retrieve the first character, and call the Substring() method to retrieve the rest of the string.

    DBEntities Context = new DBEntities ();  
    var UserNameEntity = (from a in Context.UserInformation
                         where a.UserId == UserId
                         select a).First();
    string UserName = char.ToUpper(UserNameEntity.FirstName[0])
                      + UserNameEntity.FirstName.Substring(1)
                      + " "
                      + char.ToUpper(UserNameEntity.LastName[0])
                      + UserNameEntity.LastName.Substring(1);
    
    return UserName;
    

    This assumes that both properties are at least two characters in length.

    You can also do this entirely in LINQ:

    DBEntities Context = new DBEntities ();  
    IEnumerable<string> userNames = from a in Context.UserInformation
                                    where a.UserId == UserId
                                    let firstName = a.FirstName
                                    let lastName = a.LastName
                                    select (char.ToUpper(firstName[0])
                                        + firstName.Substring(1)
                                        + " "
                                        + char.ToUpper(lastName[0])
                                        + lastName.Substring(1));
    
    return displayNames.First();
    

    Obviously, using String.Format instead of concatenation may or may not improve readability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to capitalize first letter of each sentence? public static string CapitalizeEachWord(this
Possible Duplicate: Capitalize first letter of string in javascript How do I make the
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Regular expression, split string by capital letter but ignore TLA I have
Possible Duplicate: Capitalize First Char of Each Word in a String Java What would
Possible Duplicate: Capitalize First Char of Each Word in a String Java I have
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: Why should I capitalize my SQL keywords? hi, I'm pretty new to
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.