C# TutorialLesson 8Free preview
C# Data Types
This lesson is part of C# · All levels
Summary
C# has primary data types such as int, double, string, bool, and char which each store different data forms. Types are also available for larger numbers such as long and decimal, as well as object types as the basis of all types. Choosing the right type is important to save memory and accurate calculations.
Key points
- Int stores integers, decimal numbers, text strings, bool true or false, and one character char.
- Long is used for very large integers, decimal for decimal numbers that require high precision like finance.
- The string keeps a sequence of characters, whereas the char is just one character written with a single quotation mark.
- All other types are rooted in objects, so they can be wrapped (boxing) if necessary.
- The type of a value can be checked using the GetType().Name method.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.