This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Sunday, April 12, 2020

data types in c# with examples

data types in c# with examples


In this Article today learn data types in c# with examples. with Output then c# provides different data types.

Type

Description

Range

Suffix

byte

8-bit unsigned integer

0 to 255

sbyte

8-bit signed integer

-128 to 127

short

16-bit signed integer

-32,768 to 32,767

ushort

16-bit unsigned integer

0 to 65,535

int

32-bit signed integer

-2,147,483,648
to
2,147,483,647

uint

32-bit unsigned integer

0 to 4,294,967,295

u

long

64-bit signed integer

-9,223,372,036,854,775,808
to
9,223,372,036,854,775,807

l

ulong

64-bit unsigned integer

0 to 18,446,744,073,709,551,615

ul

float

32-bit Single-precision floating point type

-3.402823e38 to 3.402823e38

f

double

64-bit double-precision floating point type

-1.79769313486232e308 to 1.79769313486232e308

d

decimal

128-bit decimal type for financial and monetary calculations

(+ or -)1.0 x 10e-28
to
7.9 x 10e28

m

char

16-bit single Unicode character

Any valid character, e.g. a,*, \x0058 (hex), or\u0058 (Unicode)

bool

8-bit logical true/false value

True or False

object

Base type of all other types.

string

A sequence of Unicode characters

DateTime

Represents date and time

0:00:00am 1/1/01
to
11:59:59pm 12/31/9999



follow the data types in c# with examples with Output:


using System;
namespace DataTypesApplication {

 class Program {
  static void Main(string[] args) {
   int num = 12;
   Console.WriteLine("num : {0}", num);

   char ch = 'a';
   Console.WriteLine("ch : {0}", ch);

   float fl = 12.75f;
   Console.WriteLine("fl : {0}", fl);

   string name = "Tim";
   Console.WriteLine("name : {0}", name);

   bool val = true;
   Console.WriteLine("val : {0}", val);

  }

 }
}



Output:

num : 12
ch : a
fl : 12.75
name : Tim
val : True



No comments:

Post a Comment