Substring Function
For any function there arises three basic question--:
1. What does it mean?
2. Why is this?
3. How it works?
What does it mean?
As we see SubString is a combination of two words "Sub" and "String".
String-: In Computer Science String means "A set of consecutive characters".
Sub -: Sub is basically a Latin prefix which has several meaning but the best suitable meaning for here is "part of".
So, Substring means "Part of a string".
Why is this?
So, from definition its clear that the work of substring is to extract a part of string.
How it works?
Syntax : Substring(index,length)
Here index denotes the postion from where you want to extract the string andlength denotes up to how much character you need to extract.Both contains integer value.
Example :
int ind = Convert.ToInt32(txtIndex.Text);
int len = Convert.ToInt32(txtLength.Text);
Literal1.Text = TextBox1.Text.Substring(ind,len);
For any function there arises three basic question--:
1. What does it mean?
2. Why is this?
3. How it works?
What does it mean?
As we see SubString is a combination of two words "Sub" and "String".
String-: In Computer Science String means "A set of consecutive characters".
Sub -: Sub is basically a Latin prefix which has several meaning but the best suitable meaning for here is "part of".
So, Substring means "Part of a string".
Why is this?
So, from definition its clear that the work of substring is to extract a part of string.
How it works?
Syntax : Substring(index,length)
Here index denotes the postion from where you want to extract the string andlength denotes up to how much character you need to extract.Both contains integer value.
Example :
int ind = Convert.ToInt32(txtIndex.Text);
int len = Convert.ToInt32(txtLength.Text);
Literal1.Text = TextBox1.Text.Substring(ind,len);