Build a stunning handcrafted website with IT Acumens

Main Menu

Values types in C#

Started by sukishan, Jul 11, 2009, 02:30 PM

Previous topic - Next topic


Values types in C#:
Value type stores real data. When the data are queried by different function a local copy of it these memory cells are created. It guarantees that changes made to our data in one function don't change them in some other function. Let see at a simple example:

public class IntClass
   public int I = 1;

Here we have simple class that contains only one public data field of integer type. Now have a look on its usage in main function:

static void Main(string[] args)
// test class
int i = 10;
int j = i;
j = 11;
IntClass ic1 = new IntClass();
IntClass ic2 = ic1;
ic2.I = 100;

Console.WriteLine("value of i is {0} and j is {1}",i,j);
Console.WriteLine("value of ic1.I is {0} and ic2.I is {1}",ic1.I,ic2.I);
A good beginning makes a good ending


the value type program used in .net
this program is easy to solve
and they have best example

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview