split string

Asked By sammy mc
06-Sep-10 12:00 AM
Earn up to 0 extra points for answering this tough question.
Hello techs, I have a input string str="london;usa;paris;germany"; I want to upload the flag depends on the country; wondering best way  I split str and create image object on the fly; Thank you!

  re: split string

Anand Malli replied to sammy mc
06-Sep-10 02:48 AM
Hi Sammy,

you can split the string based on separator ';'. & iterate through items to create image object on the fly....

using System;
 
public class SplitTest {
  public static void Main() {
 
    string str="london;usa;paris;germany"
 
    string [] split = str.Split(new Char [] {';'});
 
    foreach (string s in split) {
 
      if (s.Trim() != "")
         // Add code to create image object here
    }
  }
}

I hope u got ur solution....
Create New Account