Saturday, 22 March 2014

How to Convert array to string ?

Converting the list of array values into form of string, This helps  to show the value into any control or to store many values in a single database field.

How it work?  suppose you have Array like “Xx”, “ Yy” and “ Zz”,  There  you can join and get the value into string like “Xx Yy Zz”.
There is string method to make it simple to join the array and from a single string.

Code Snippet  for split string in C#

class Program
        static void Main(string[] args)
            // Create an array with five strings.
            string[] arrayValue = new string[5];
            arrayValue[0] = "Value";
            arrayValue[1] = "in";
            arrayValue[2] = "array";
            arrayValue[3] = "to";
            arrayValue[4] = "Display";
            Console.WriteLine("array values \n");
            Console.WriteLine("=================================== \n");
            foreach (var item in arrayValue)
                 Console.WriteLine(item + "\n");
            Console.WriteLine("Join values \n");
            Console.WriteLine("=================================== \n");
            string JoinValue = string.Join(" ", arrayValue);
@Out split  value
click on the link to get how to convert string to array in c#?

No comments:

Post a Comment