Nullable Types in C#.Net

If you haven’t gone through my previous article on Reference type and value type then please go through here.

What is a nullable Type ? Nullable types are special data type in C#.net, to which you can assign null value. What does that mean ? Lets say you have declared a variable as int i = 0 , Now you want to assign null to it at run-time. If you write i = null then compiler throws error as shown below. Now question arises How this can be achieved ?nullable_type_1

(more…)

Advertisements

Value Type and Reference Type in C#.Net

In C#.net, all data types are mainly classified in to two categories.

  • Value Type
  • Reference Type

Value Type – A value type holds the value itself in a stack. For example, when we declare a value type variable as  int X = 500 then the C# compiler allocates some memory space from the stack and stores the value, as shown in the image. 1.0What happens when we assign one value type to another ? If we assign a value type variable to another value type variable then the value is copied, and in that case both of the variables work independently and any change to any of the variable doesn’t affect the other.
(more…)

Data Types in C#.Net

Data types or variable are an important thing in any programming language. It is the basic starting point for a programmer. It generally tells to the compiler the type of value it can hold. In below example we have declared a string variable in C#.net as.

 String s = "Hello"

It tells to the compiler that string is a data type that will be used to hold text value.

 int i = 123 

In above example, we have declared a integer type in C#.net. It tells to the compiler that int is a type that will be used to hold numbers.

Data types has some specific size and length. If we declare a type and at run time if the value it holds exceeds the max limit that the type can hold then we get the data overflow issues. So its very important to have proper data types in our program.
Continue reading

Welcome to The Dot-net Guide :)

IMG_0126The idea behind this blogging website came to me on a fine Saturday morning. As I was  lying down on my bed and lazily browsing Facebook, then accidentally I stumbled upon an article on blogging. The article was all about “How you can blog in 100 different ways ? “. It was quite interesting to learn how people from different interest, technology share their knowledge and experience to the larger audience.

(more…)