Home  >  Article  >  Backend Development  >  How to define character constants in C#?

How to define character constants in C#?

王林
王林forward
2023-08-21 21:13:21926browse

Character literals are enclosed in single quotes. For example, 'x' can be stored in a simple variable of type char. Character literals can be ordinary characters (such as 'x'), escape sequences (such as '\t'), or universal characters (such as '\u02C0').

Let’s look at an example of defining character constants in C#:

using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         Console.WriteLine("Welcome!\t");
         Console.WriteLine("This is it!");
         Console.ReadLine();
      }
   }
}

Above, we used the new newline and horizontal tab constants −

and \t

Console.WriteLine("Welcome!\t</p><p></p><p>");
Console.WriteLine("This is it!");

The above is the detailed content of How to define character constants in C#?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete