2010/02/04

C# week2_2

Rule
  1. define variables
  2. name first letter is letter or underscore
  3. define & declaration
  4. variable can take two values
Casting
  • implicit data type casting (widening data conversion) automatically
  • explicit data type casting (narrow data conversion) if we don't indicate, it doesn't work.
ex.
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 件のコメント:

コメントを投稿

UA-9417263-1