How to declare and print char array in C#

3 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] arr = { 'c', '#', ' ', 'j', 'a', 'v', 'a' };

            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine(arr[i]);
        }
    }
}


/*
run:
  
c
#

j
a
v
a
 
*/

 



answered Jan 10, 2017 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] arr = new char[]  { 'c', '#', ' ', 'j', 'a', 'v', 'a' };

            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine(arr[i]);
        }
    }
}


/*
run:
  
c
#

j
a
v
a
 
*/

 



answered Jan 10, 2017 by avibootz
0 votes
using System;

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

            arr[0] = 'c';
            arr[1] = '#';
            arr[2] = '.';


            for (int i = 0; i < arr.Length; i++)
                Console.WriteLine(arr[i]);
        }
    }
}


/*
run:
  
c
#
.
 
*/

 



answered Jan 10, 2017 by avibootz

Related questions

5 answers 329 views
1 answer 111 views
111 views asked Aug 5, 2022 by avibootz
1 answer 179 views
2 answers 213 views
...