Home > Backend Development > C#.Net Tutorial > How to define character constants in C#?

How to define character constants in C#?

王林
Release: 2023-08-21 21:13:21
forward
964 people have browsed it

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();
      }
   }
}
Copy after login

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!");
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template