
- 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 and String data types in C#?
String stands for System.String whereas string is an alias in C# for System.String −
For example −
string str = "Welcome!";
It’s not essential, but generally String is used when you work with classes −
string str = String.Format("Welcome! {0}!", user);
Since string is an alias for System.String. The alias for other datatypes are −
EXample
object: System.Object string: System.String bool: System.Boolean float: System.Single double: System.Double decimal: System.Decimal byte: System.Byte sbyte: System.SByte short: System.Int16 ushort: System.UInt16 int: System.Int32 uint: System.UInt32 long: System.Int64 ulong: System.UInt64 char: System.Char
The String type in C# allows you to assign any string values to a variable. The string type is an alias for the System.String class. It is derived from object type. The value for a string type can be assigned using string literals in two forms − quoted and @quoted.
Output
String str = "Okay!";
- Related Articles
- Java String Concatenation with Other Data Types.
- What are JavaScript data types and data structures?
- How to add string and other data types for Listview in Android?
- What are the data types, value types and reference types in C#?
- What are compound data types and data structures in Python?
- Difference between string and char[] types in C++
- What are primitive data types in Java?
- What are reference data types in Java?
- What are primitive data types in JavaScript?
- What are enumerated data types in C++?
- What are Complex Data types in JavaScript?
- What are pointer data types in C#?
- What are nullable data types in C#?
- What are dynamic data types in C#?
- What are object data types in C#?

Advertisements