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?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Aug 26, 2013, 1:42 AM
string value = DropDownList1.SelectedValue.ToString();
char first = value[0];
Hardik PatelPosted Aug 26, 2013, 1:36 AM
Rosi Sreenivasa ReddyPosted Aug 26, 2013, 1:19 AM
your code working nicely..............
Jaganathan BantheswaranPosted Aug 26, 2013, 1:09 AM
char first = value.First(); // OR value.FirstOrDefault();
If you included reference for Linq, the above wil work.
Sanjeeb LenkaPosted Aug 26, 2013, 12:53 AM
string value = "Hardik";
char first = value[0];