主要的数据类型:
int 32
long 64
float 32
double 64
decimal 128
string 16每个字符
char 16
bool 8
书上说C#定义变量后必须赋初值,如果不赋初值就会编译出错.
我感觉这真是一个好的约定.能减少程序出错.
操作符
算数操作符:+加 –减 *乘 /除 %求余 ++自加 --自减
这里面 ++ -- 也和C/C++ 一样有 变量++/-- ++/--变量
如果想控制优先级,通过括号,就可以控制了
函数定义方法:
书上记录:
returnType methodName (parameterList)
{
//method body statements go here
}
函数返回值 函数名 (参数列表)
{
函数体(函数的具体实现部分)
}
C, C++, and Microsoft Visual Basic programmers should note that C# does not support global methods. You must write all your methods inside a class, or your code will not compile.
看书上写的注意事项:
1 C#没有全局函数,所有的函数,就是所谓的方法都要写到类class里面,否则不能编译
2 C#函数也支持重载(overloading)