hi all,
I have a string "FS:A151940.A-CM4;4" and have a integer value stored in a variable num.... now i want the string to be modified as "FMS:A151940.A-CM4;*" where value of num must be present instead of *... please help me out with this !!
sidhu51 0 Newbie Poster
Recommended Answers
Jump to PostI am a little confused
"FS:A151940.A-CM4;4"
"FMS:A151940.A-CM4;*"Does the M mean anything or is it a Typo
you have to use the Replace command.
string code = "FS:A151940.A-CM4;*" int num = 5; code = code.Replace("*",num.toString()); MessageBox.Show(code);
String.Replace("oldText","newText");
Basically search for oldText and replace it …
Jump to Postif the string you mentioned will be the same until the semicolon, you can use something like this
string MyString = "FS:A151940.A-CM4;4"; string aString = MyString.Substring(0, MyString.IndexOf(';')) + value.ToString();
Ionut
All 8 Replies
finito 46 Nearly a Posting Virtuoso
sidhu51 0 Newbie Poster
finito 46 Nearly a Posting Virtuoso
sidhu51 0 Newbie Poster
finito 46 Nearly a Posting Virtuoso
Ionelul 7 Junior Poster in Training
finito 46 Nearly a Posting Virtuoso
sidhu51 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.