
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are string literals in C#?
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.
Here are some examples of String Literals −
“Hi, User" "You’re Welcome, \
The following is an example showing the usage of string literals −
Example
using System; namespace Demo { class Program { static void Main(string[] args) { // string string str1 ="Hello, World"; Console.WriteLine(str1); // Multi-line string string str2 = @"Welcome, Hope you are doing great!"; Console.WriteLine(str2); } } }
Output
Hello, World Welcome, Hope you are doing great!
- Related Articles
- What are Perl String Literals?
- What are string literals in C language?
- What is the difference between character literals and string literals in Java?
- What are literals in Java?
- What are literals in C++?
- What are Literals in Python?
- What are JSP literals?
- What are Boolean literals in Java?
- What are Boolean Literals in C++?
- What are Character Literals in C++?
- What are integer literals in C#?
- What are Perl Numerical Literals?
- Formatted string literals in C#
- What are floating point literals in C#?
- What is the type of string literals in C/ C++?

Advertisements