Topic: How To Convert One To Another Data Type
Just an intorduction for converting one data type to another data type
You are not logged in. Please login or register.
Just an intorduction for converting one data type to another data type
string to another :
int a=int.Parse("1");
or
int a;
int.TryParse("1",out a);
it seems different from c programming completely, as i know this now
. It can be done by casting easily with c
There is a difference between string in character in C. ![]()
in C.
char s[2] = "1";
int i=0;
// one way
i=(int)(s[0] - '0');
// wont work
i = (int)s;OT:
The C/C++ equivalents are atoi(), atof() etc.
char s[10] = "123";
int i;
i = atoi(s);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-----
C# is case-sensitive. So be careful with that. It must be
int a = Convert.ToInt16(s);
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 .
Posts [ 10 ]
Powered by PunBB