- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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!";
Advertisements