Wednesday, March 12, 2014

Convert list to string Scenario

       Dim dests As String = ""
        Dim seprateDests As String = ""
        Dim selectedCountries As List(Of String) = objData.Destination.Split(" ").ToList()
        For Each country In selectedCountries
            dests = country.Split(",")(1).ToString()
            seprateDests += dests.Replace("-", " ") + ","
        Next

----------------------------------
List<string> dogs = new List<string>(); // Create new list of strings
 dogs.Add("Aigi"); // Add string 1
 dogs.Add("Spitz"); // 2
 dogs.Add("Mastiff"); // 3
 dogs.Add("Finnish Spitz"); // 4
 dogs.Add("Briard"); // 5

 string dogCsv = string.Join(",", dogs.ToArray());
 Console.WriteLine(dogCsv);

No comments:

Post a Comment