Hi!
Well, in your case you could simply use the string.Substrin g(int index, int
length) to get the string you need.
string b = a.Substring(sta rt, end-start);
Fairly simple.
If you on the other hand want to add characters and so on you could alway
use the StringBuilder (System.Text)
System.Text.Str ingBuilder sb = new StringBuilder(s tring.Empty); //A new
totally empty stringbuilder
for (int i = start; i < end; i++)
{
sb.Append(str[i])
}
return sb.ToString(); //returns the string you wanted
I hope this helps!
//Mikael
"Stu Banter" <x2************ **@westerterp.c om> wrote in message
news:3f******** *************** @dreader9.news. xs4all.nl...
I used a PERL primer for my knowledge of RegExp.
Many to be found as ebooks online, for free. Maybe useful ?
Best
Stu
"J. Oliver" <jo*********@sp amex.com> wrote in message
news:9d******** *************** ***@posting.goo gle.com... I am attempting to copy a portion of a string into another string. Say
I have "abcdef" in string 'a' and want to copy only "bcd" into a new
string 'b'. The following function came to mind:
public string GetText(string a, int start, int end)
{
int i;
string b;
for (i=0;i<(end-start);i++)
{
b[i]=(a[start+i]);
}
return b;
}
At compile time, I am getting the error: "Property or indexer
'string.this[int]' cannot be assigned to -- it is read only"
Which makes sense, since I am attempting to increase the sisce of a
fixed string. Is there an easier way to do this?
- j. oliver