count no of characters from string
startIndex = k.IndexOf(" 43 ");
string test3 = k.Substring(startIndex, 32);
startIndex1 = k.IndexOf(" 54 ");
string test4 = k.Substring(startIndex, 55);
how to count no of characters between 2 indexes(startIndex and startIndex1) from a string in c#?
Roei BarPosted Sep 17, 2009, 7:38 AM
startIndex = k.IndexOf(" 43 ");
startIndex1 = k.IndexOf(" 54 ");
string test3 = k.Substring(43, 54-43);
then
int _totalChars = test3.Trim().Length;
Kirtan PatelPosted Sep 17, 2009, 5:00 AM
Dont forget to mark "Do you like answer" if answer helped you :)
Hi, mittal
Here is Code for it it it is not what you want then provide me sample String on Which you re performing the operation and Also tell me What you want as Result
private void button1_Click(object sender, EventArgs e)
{
string x = textBox1.Text.Trim();
int Index1 = x.IndexOf("43");
int Index2 = x.IndexOf("54");
MessageBox.Show("Number of Chars Between :=" + (Index2 - Index1-1).ToString());
}