Search This Blog

Monday 6 July 2015

Print a character in C# or Print a character using c sharp or Print character & binary number of characters in c#

Step 1:- Method

public char[] PrintCharacter()
        {
            char[] strChar = new char[26];
            for (int i = 0; i < 26; i++)
            {
                strChar[i] = (char)('A' + i);

                Console.WriteLine("Character {0} Binary Number {1}", strChar[i], ('A' + i));
            }
            return s;
        }

Step 2:- Complete code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Console_Application_Demo
{
    class Program
    {
        public char[] PrintCharacter()
        {
            char[] s = new char[26];
            for (int i = 0; i < 26; i++)
            {
                s[i] = (char)('A' + i);

                Console.WriteLine("Character {0} Binary Number {1}", s[i], ('A' + i));
            }
            return s;
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            p.PrintCharacter();

            Console.ReadLine();
        }
    }
}

Example:-




No comments:

Post a Comment