How to use WriteLine() method of Console class in C#?

CsharpProgrammingServer Side Programming

WriteLine() is a method of the Console class defined in the System namespace

This statement causes the message "Welcome!" to be displayed on the screen as shown below −

Example

 Live Demo

using System;
namespace Demo {
   class Test {
      static void Main(string[] args) {
         Console.WriteLine("Welcome!");
         Console.ReadKey();
      }
   }
}

Output

Welcome!

To display a char array using the Console.WriteLine.

Example

 Live Demo

using System;
namespace Demo {
   class Test {
      static void Main(string[] args) {
         char[] arr = new char[] { 'W', 'e'};
         Console.WriteLine(arr);
         Console.ReadKey();
      }
   }
}

Output

We
raja
Published on 18-Sep-2018 17:26:50
Advertisements