---
title: "Fundamental of C Sharp"  
description: "It is a placeholder in the memory that can be used to store the data,its value can be changed, using the data type we can specify that what kind of va"  
author: "Manish Kumar"  
published: 2017-02-26  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11307/fundamental-of-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# Fundamental of C Sharp

## 1-Variable

It is a placeholder in the memory that can be used to store the data,its value can be changed, using the data type we can specify that what kind of value will be stored in the variable.

**Syntax**

<data_type><variable_Name>

**Example**

```
string name; int age; float
percentage;
```

## \

**Data type-**\

It is divided into following two types:

a-value type/simple type/primitive type

b-[reference type](https://www.mindstick.com/interview/235/what-is-difference-between-value-types-and-reference-types-in-vb-dot-net-or-c-sharp-value-types-vs-reference-types)/complex type/non-primitive type

value-It is used to [store the value](https://answers.mindstick.com/qa/35621/how-would-you-store-the-value-of-a-color-in-a-database-as-efficiently-as-possible) and can be directly accessed i.e.

**Major data types of value type:**

**a-**Numeric i.e. 0-9 or decimal

**b-**String and Char i-e. 0-9, a-z, special char,but char can store only single char at a time while string can store many chars

**c-**Boolean-can store only true or false 0 or 1

**Numeric-**it will store only 0-9, it is furture divided as:

**Integer-**it will store only whole number

Short integer, long integer, very long integer

**Float-**it can store decimal as well as float, double

**String and Char-**it can store anything from a-z, 0-9 or special chars

**Sting-**can Store number of characters

**Char-**will store only single char

**Boolean-**it will accept only true or false or 0 or 1

**Literals-**A Literal is a type of value that is stored in a variable

**Integer Literal -**can store only whole number i.e.

Int age=25; //correct

Int age=25.5;//incorrect

Floating point literal-It can accept decimal i.e

Float age=25; //correct

Float age=25.5;

**String literal-**It will accept anything but will be enclosed in the double quotes i.e.

***Eg.***

```
      string name = "Ram";//correct     string email = "ram@mindstick.com";//correct     string name = ram;//wrong     string name='ram'//wrong
```

**Character Literal-**it will accept anything but only single char and will be enclosed in the single quotes i.e.

```
            char gender = ‘M’;//correct            char gender = "Male";//incorrect            char gender = ram;//wrong            char type='ram'//wrong
```

**Boolean Literal-** It will accept only true/false or 0/1 i.e.

```
            boolean staus = true;//correct            boolean status = 0;// correct            boolean status = ram;//wrong            char type='ram'//wrong
```

**Identifier-** it is name given to variable,constant,function,array

***i.e,***

```
            int salary;//correct            int = data type;// correct            salary  = identifier;//wrong
```

**Constant-**

It has the fixed value that cannot be changed during the program execution.We have to initialize the constant while declaring it.

To declare the constant const keyword is used i.e.

```
  const int age=20;
```

**You can visit these related useful post**

[**Abstraction in c# with example**](https://www.mindstick.com/Blog/319/abstraction-in-c-sharp-with-example)

[**Threading in C# with Example**](https://www.mindstick.com/Articles/630/threading-in-c-sharp-with-example)

[**Identifiers in c#**](https://www.mindstick.com/blog/91/identifiers-in-c-sharp)

[**Inheritance in C#.Net**](https://www.mindstick.com/Articles/80/inheritance-in-c-sharp)

[**Calculator Program in C# .NET**](https://www.mindstick.com/Articles/47/calculator-program-in-csharp-dot-net)

[**Datagridview Printing in C#**](https://www.mindstick.com/Articles/1356/datagridview-printing-in-c-sharp)

[**Insert, Delete, Update in DataGridView with DataTable in C#**](https://www.mindstick.com/Articles/965/insert-delete-update-in-datagridview-with-datatable-in-c-sharp)

---

Original Source: https://www.mindstick.com/blog/11307/fundamental-of-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
