Hi
I am having doubt on C# this topic, For example
string s = "Raj Kumar SO#Wo TEXAS AVE"
I have to check where # is present and have to take the part "Raj Kumar" alone not 'SO#' includes
Hi G.RajKumar,
Refer below sample.
Code
C#
protected void Page_Load(object sender, EventArgs e) { string str = "Raj Kumar SO#Wo TEXAS AVE"; int index = str.IndexOf(" SO#Wo"); string result = str.Substring(0, index); }
Refer below code.
protected void Page_Load(object sender, EventArgs e) { //Here we take the string. string str = "Raj Kumar SO#Wo TEXAS AVE"; //Splits the string on the basis of # in two parts. string[] parts = str.Split('#'); //further Splits the first half of string on the basis of blank space. string[] nameParts = parts[0].Split(' '); //Concat the string with the help of index. string result = nameParts[0] + " " + nameParts[1]; }
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.