C-Sharp Introduction | Data types of C#






C# is an elegant object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework.
You can use C# to create Windows applications, Web services, mobile applications, client-server applications, database applications, and much, much more.

Applications written in C# use the .NET Framework and its components.
The .NET Framework consists of the Common Language Runtime (CLR) and the .NET Framework class library.
The CLR is the foundation of the .NET Framework. It manages code at execution time, providing core services such as memory management, code accuracy, and many other aspects of your code.
The class library is a collection of classes, interfaces, and value types that enable you to accomplish a range of common programming tasks, such as data collection, file access, and working with text.
C# programs use the .NET Framework class library extensively to do common tasks and provide various functionalities.

DATA TYPES:


First we learn about the data types in C#, in computer programming datatypes are the classification of data that tells the compiler which type of data user give the input to the program, these are the dataypes in C#, Download Visual Studio for coding from here :


Byte:

Byte is the datatype of C# and its memory is 1 Byte and the range of Byte is 0 to 255, it means that You can give input numbers from 0 to 255, if u Put a number which is greater than 255 than it will give an error or give another number. i.e 12,10,16,200,255. In Byte datatype 255 is the maximum number. Short: Short is also the datatype of C# and its syntax is Int16 in .net frame work and its memory is 2 Bytes and it can store a number from 32,768 to 32,767. It can Only store integer number which is not in decimal form i.e 1230,122,100,1762 etc.

Short: 

Short is also the datatype of C# and its syntax is Int16 in .net frame work and its memory is 2 Bytes and it can store a number from 32,768 to 32,767. It can Only store integer number which is not in decimal form i.e 1230,122,100,1762 etc

Int:

Int is also the datatype of C# and its syntax is Int32 in .Net framework and its memory is 4 Bytes and it can store number from -2.1B to 2.1B, It can only store Integer number.

Long: 

Long is same as Int or short but syntax is little bit changed its syntax is Int64 in .Net Framework and its memory is 8 Bytes and it is used for Store the large data, it is used little bit because we can do everything with Int or short Datatype, because they can store billions of numbers.

Float, Double and Decimal: 

Float, double and decimal are the data types of C# its is used for storing the real numbers , it can store the decimal numbers , its memory information is mention in the above picture , i.e 121.63, 1726.54f, 8171.2 etc.

Char: 

Char is used for store a single character It may be any alphabet, digit, or special symbol and its syntax is :
char a= ‘B’; char a= ‘6’; char a= ‘*’ 
in the above statement “char” is the datatype, “a” is the variable which we learn later ‘ ’ single quotation mark is used for specify the character and inside the quotation mark we can write our character same as I write above.

Bool:

Bool/Boolean is the datatype of C# and it used for the true/false statement, its memory is 1Byte.

String: 

String is also the datatype of C#. You can store numbers, words, or special symbols in it inside the double quotation marks “ ”. Its syntax given as follows: 

string name = “John”;----------------------1
 string aa = “$HelloWorld012$”;---------------2
In statement no. 1 “string ” is the datatype and “name” is the variable and after the equal sign inside the double quotation mark “John” is the value of variable name.

In statement no. 2 “string ” is the datatype and “aa” is the variable and after the equal sign inside the double quotation mark “$HelloWorld012$” is the value of variable name.



C-Sharp Introduction | Data types of C# C-Sharp Introduction | Data types of C# Reviewed by Developer Planet on October 21, 2018 Rating: 5

No comments:

Advertising

Powered by Blogger.