Sep 20, 2011

Array of string in C#

using System;

namespace arrayDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = new string[3];

            arr[0] = "exact";
            arr[1] = "help";
            arr[2] = "@blogspot.com";

            //printing value of each element in the array
            foreach (string element in arr)
            {
                Console.Write("{0}", element);
            }
            Console.ReadKey();
        }
    }
}

using System;

namespace arrayDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = {"exact","help","@blogspot.com"};
          

            //printing value of each element in the array
            foreach (string element in arr)
            {
                Console.Write("{0}", element);
            }
            Console.ReadKey();
        }
    }
}

exacthelp@blogspot.com

string[] arr = new String[3]{"exact","help","@blogspot.com"};

No comments:

Post a Comment