- define variables
- name first letter is letter or underscore
- define & declaration
- variable can take two values
- implicit data type casting (widening data conversion) automatically
- explicit data type casting (narrow data conversion) if we don't indicate, it doesn't work.
1) OK widening data conversion
int i =10;
double d = i;
2)Error narrow data conversion
double d = 10.5;
int i = d;
3)OK narrow data conversion
double d = 10.5;
int i = (int)d;
4)Error data type conversion must be compatible (changeable).
string s = "abc";
double d = (double)s;
5)OK char:0-255
char c = 'A';
int j = c;
6)Same meaning
int i = 100;
long l = (long)i; / long l = 100L;
0 件のコメント:
コメントを投稿