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


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

Updated on: 23-Jun-2020

227 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements