Study Note:CSIN3 Chapter 2: C# Language Basic
来源:互联网 发布:汽车诊断软件笔记本 编辑:程序博客网 时间:2024/06/07 07:38
I should familiar with this chapter. If not, I should hit the wall.
2.1 A First C# Program
I'm very glad to see the first C# program is not a hello world program. :-)
The first program introduce the variable, method, Main, Class, Namespace.
Nothing important to me, I think.
2.2 Syntax
Identifiers: The name of the class, method, variable, namespace and so on. Start with Unicode character or under score. C# is case-sensitive.
Keywords: The words system choose which can't be an identifier, reserved word. You can use prefix @ to use a keyword as identifier. Then you can use it like "@class". But if you use prefix @ to a common identifier, the "@a" and "a" is the same.
Contextual Keywords: I don't know it exactly, maybe they are recognized as keywords in special area.
Literals: Data in the code.
Punctuators: Separator. E.g. , ; {}
Operators: Transform and combine expressions. E.g. + - * /
Comments: // single line comment /* */ multiline comment
I decide to not note all the things, it is too much to note, oops. I just note the useful information.
2.3 Type Basics
- Predefine types and Custom types
- Value types, Reference types and Pointer types
- Different of value type and reference type
- Memory allocate: value just an object, reference has a reference and an object
- Copy: value copy the object, reference copy the reference means point the same object
- Different of value type and reference type
- Struct is a Custom Value type
2.4 Numeric Types
Numeric Literal inference: I use to think is totally wrong.
If there is a decimal point then the literal is a double , else it is a int or long and so on
Checked and Unchecked operator
Real number rounding error: see some statements
decimal m = 1M / 6M; // 0.1666666666666666666666666667M
double d = 1.0 / 6.0; // 0.16666666666666666
decimal notQuiteWholeM = m+m+m+m+m+m; // 1.0000000000000000000000000002M
double notQuiteWholeD = d+d+d+d+d+d; // 0.99999999999999989
double d = 1.0 / 6.0; // 0.16666666666666666
decimal notQuiteWholeM = m+m+m+m+m+m; // 1.0000000000000000000000000002M
double notQuiteWholeD = d+d+d+d+d+d; // 0.99999999999999989
So don't use float or double to financial calculation, I think.
2.5 Boolean Type and Operators
Bool alias System.Boolean
Bool value can't convert to numeric types
Condition operators(&& || !) short-circuit evaluation when possible, &, | don't do short-circuit evaluation
2.6 Strings and Characters
Escape characters: /u Unicode
@: verbatim string
2.7 Arrays
Declaration:
C#: int[] array = new int[5]; In actually, int[] array is declaration, and new int[5] is initialize
C++: int array[5];
Default initialize: value type 0 or false and so on, reference type is null
Multidimensional array:
rectangular array: int[,] array = new int[3,3];
Jagged Array: int[][] array = new int[3][]; array[0] = new int[4];
Var: I think it will be introduce more in later chapter
2.8 Variables and Parameters
Memory allocate: stock and heap
Stock: local variables and parameters
Heap: New objects
Definite Assignment:
- Local variables must be assigned a value before they can be read.
- Function arguments must be supplied when a method is called.
- All other variables (such as fields and array elements) are automatically initialized by the runtime.
Default Value:
Reference null
Numeric type or Enum type 0
char type '/0'
bool type false
Parameter pass style
None
Value
Going in
Ref
Reference
Going in
Out
Reference
Going out
2.9 Expression and Operators
Operator Precedence
2.10 Statements
Goto in switch
Goto case 12;
2.11 Namespace
Some advantage feature: I don't think it is very import, and I don't know some of them well, NEED TO READ AGAIN
- Study Note:CSIN3 Chapter 2: C# Language Basic
- php study note 2 --- basic syntax
- 《AspectC++ Language Reference》Chapter 2 Basic Concepts
- Study Note:C# in a Nutshell-Chapter 1 Introducing C# and the .NET Framework
- C# basic study
- CORE JAVA study note(CHAPTER THREE)
- Chapter 1. C# Language Elements
- perl study note-2
- jQuery study note 2
- LDD3 study note 2
- Assmebly Language Note(2)
- My study note of PHP language(I)
- My study note of PHP language(II)
- My study note of PHP language(III)
- My study note of PHP language(IV)
- My study note of PHP language(V)
- MySql study note 2 ---mysqladmin
- DOJO Study Note(2) --AJAX
- Trac+subversion拥有强大的bug管理能力
- 让我们提防像汇丰这样的外资银行
- 我的软件工程
- Edit Controls(转载)
- 求Visual c++数字图象处理(人邮出版)的光盘源代码
- Study Note:CSIN3 Chapter 2: C# Language Basic
- 字符UNICODE的各种转换(转载)
- 软件设计师考试
- 在vc中实现获取汉字拼音的首字母(转载)
- 充分发掘Subversion的资源库共享功能
- 人工智能
- Windows下架设Subversion服务器
- ORACLE常用日期转换处理
- 开始学习svg