for Example, From Hardik i want only H from this
How to get first character from string in asp.net?
how to get first character from string in asp.net?
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 25, 2013, 8:53 PM EDT
string value = "Hardik";
char first = value[0];
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Aug 25, 2013, 9:09 PM EDT
char first = value.First(); // OR value.FirstOrDefault();
If you included reference for Linq, the above wil work.
Rosi Sreenivasa Reddy137 reputationPosted Aug 25, 2013, 9:19 PM EDT
your code working nicely..............
Hardik PatelRank #4,439 · 343 reputationPosted Aug 25, 2013, 9:36 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 25, 2013, 9:42 PM EDT
string value = DropDownList1.SelectedValue.ToString();
char first = value[0];