DataType Convertion In

To Convert the Base Data Type To an other Base Data Type,we use “Convert” class and its functions the target Data Type,Check the below example

int i;
 for (i = 0; i < 5; i++)
 MessageBox.Show(Convert.ToString(i), "Integer To String", MessageBoxButtons.OK, MessageBoxIcon.Information);


we use one integer type variable “i”.and use “for” loop to increment the value of “i” and display the message box.

Convert.ToString(i),is responsible to convert the integer value to string, and message box is only show the string value so i use the Convert.ToString(i) inside the message box.

The above Example is convert the base data type Integer to other base data type String.

It is not only convert the integer data type to string, but its able to convert any base data type to other base data type.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.