Topic: How To Convert One To Another Data Type

Just an intorduction for converting one data type to another data type

Re: How To Convert One To Another Data Type

string to another :

int a=int.Parse("1");

or

int a;
int.TryParse("1",out a);

Re: How To Convert One To Another Data Type

it seems different from c programming completely, as i know this now sad . It can be done by casting easily with c big_smile

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: How To Convert One To Another Data Type

Tareq wrote:

it seems different from c programming completely, as i know this now sad . It can be done by casting easily with c big_smile

There is a difference between string in character in C. tongue

in C.

char s[2] = "1";
int i=0;
// one way
i=(int)(s[0] - '0');
// wont work
i = (int)s;
http://url.ie/zybhttp://url.ie/zydhttp://url.ie/zyc
মুখে তুলে কেউ খাইয়ে দেবে না। নিজের হাতেই সেটা করতে হবে।

Re: How To Convert One To Another Data Type

shiplu wrote:

There is a difference between string in character in C. tongue
in C.

i=(int)(s[0] - '0');

waiting

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: How To Convert One To Another Data Type

OT:
The C/C++ equivalents are atoi(), atof() etc.

char s[10] = "123";
int i;

i = atoi(s);

Re: How To Convert One To Another Data Type

Oh ya, it can be easily done by this built-in function. I forget it big_smile

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: How To Convert One To Another Data Type

In C# it is very easy to convert one to another there are several built in methods to convert

Examle:
string s="123";
int a=convert.ToInt16(s);
it can be used in vice versa-----

Re: How To Convert One To Another Data Type

C# is case-sensitive. So be careful with that. It must be

int a = Convert.ToInt16(s);

Re: How To Convert One To Another Data Type

int a;
float b=4.556F; // must use an ' F ' for float number . Double number no need 'F'
double d=4.556;
a = (int)b;  // this type of conversion also possible like c. so output will be 4 .