# Character constants vs String literals in C#

CsharpProgrammingServer Side Programming

## Character constants

Character literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as '\t'), or a universal character (such as '\u02C0').

Certain characters in C# are preceded by a backslash. They have special meaning and they are used to represent like newline (\n) or tab (\t).

## Example

Live Demo

using System;
namespace Demo {
class MyApplication {
static void Main(string[] args) {
Console.WriteLine("Welcome\t to the website\n\n");
}
}
}

## Output

Welcome to the website

## String literals

String literals or constants are enclosed in double quotes "" or with @"". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters.

Published on 17-Sep-2018 16:15:55