
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Character constants vs String literals in C#
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
using System; namespace Demo { class MyApplication { static void Main(string[] args) { Console.WriteLine("Welcome\t to the website\n\n"); Console.ReadLine(); } } }
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.
- Related Questions & Answers
- Difference between C++ string constants and character constants
- Type difference of character literals in C vs C++
- Integer literals vs Floating point literals in C#
- What are C++ Character Constants?
- What are Character Literals in C++?
- What is the difference between character literals and string literals in Java?
- How to define character constants in C#?
- Formatted string literals in C#
- Data type of character constants in C and C++
- What are Backslash character constants in C language?
- Type difference of character literals in C and C++
- Object literals vs constructors in JavaScript
- What are string literals in C#?
- What are string literals in C language?
- How do I define string constants in C++?
Advertisements