C# Data Types

Before discussing C# Data Types, you should know the word datatype. So what is a data type? It is the type of data that a variable can store in the form of value. It can be of any kind, i.e., numerical data, textual data, character data, etc. I hope you got it. If you still have any queries related to C# Data Types, comment below. Now let’s discuss datatypes in C#.

C# Data Types

C# Data Types Description

There are several C# Data Types look below:

Data typeSize of DatatypeDescription of data type
int4 bytesStores whole numbers, without decimals / positive or negative
float4 bytesStores fractional numbers, containing one or more decimals. Sufficient for storing 6-7 decimal digits
double8 bytesStores fractional numbers, containing one or more decimals. Sufficient for storing 15 decimal digits
char2 bytesStores a single character/letter/number, or ASCII values and it is surrounded by single comma like ‘a’
bool1 bitStores true or false values or on or off like
string2 bytes per characterStores a sequence of characters(i.e text), surrounded by double quotes(“”)
long8 bytesStores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Basic C# Data Types
C# Data Types

Declaring Variable with C# Data Types with output

using System;

namespace Codelikechamp
{
  class Program
  {
    static void Main(string[] args)
    {
      int Num = 5;               // integer (whole number)
      double DoubleNum = 5.99D;  // floating point number
      char Letter = 'D';         // character
      bool Bool = true;          // boolean
      string Text = "Hello";     // string
      Console.WriteLine(Num);
      Console.WriteLine(DoubleNum);
      Console.WriteLine(Letter);
      Console.WriteLine(Bool);
      Console.WriteLine(Text);
    }
  }
}

Output of C# Data Types

5
5.99
D
true
Hello

Learn more about C#

Link: https://Codelikechamp.com

Medium Link: Follow me on Medium

Linkedin Link: Follow me on Linkedin

🤞 Don’t miss any latest posts!

Please subscribe by joining our community for free and stay updated!!!

IF YOU HAVE ALREADY SUBSCRIBED JUST CLOSE THIS FORM !

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top