C# 类的介绍,参数传递,各种符号说法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HappyProject { public class Happy { public const string Slogan = "You are happy!"; private DateTime when; private string why; public DateTime When { get; set; } public string Why { get; set; } } public class UnHappy { public const string Slogan = "You are unhappy!"; private DateTime when; private string why; public DateTime When { get; set; } public string Why { get; set; } } }
写了两个类,没什么用呢。
类中的数据和函数称为类的成员。成员的可访问性可以是 公共的,保护的,内部的,私有的。
数据成员是包含类的数据,废话,字段(field),常量,我的那两个类都有了呢~事件我的类里面还没有。数据成员可以是static的,也可以是实例成员。
事件是类的成员,在发生某些行为(如改变类的字段或属性,或者进行了某种形式的用户交互操作)时候,它可以让对象通知调用方。客户可以包含所谓“事件处理程序”的代码来响应该事件,以后再说,树上写的,不是我说的哦。
函数成员提供了操作类中数据的某些功能。包括方法、属性、构造函数和终结器(finalizer)、运算符以及索引器。函数成员可以是static的(静态方法),也可以是实例成员(default)。
Property is a method group which we can visit from client. How to visit? Object.Property. C#为都读写类中的属性提供了专用语法,所以不必使用那些名称中嵌有Get或者Set的方法。因为属性的这种语法不同于一般函数的语法,,在客户端的代码中,虚拟的对象被当作实际的东西。
Constructor构造函数是在实例化对象时自动调用的 auto-invoke的特殊函数。他们必须与所属的类同名,这个知道,且不能有返回类型。构造函数用于初始化字段的值。
Finalizer is something like constructor. When CLR detects an object won‘t be used any more, it would invoke finalizer. Their name is the same with Class, but has a bolang line. 查了一下,叫tlide。附上这个。
“-”叫【破折号】(中文的长),属于中文使用的,英文中叫“dash”;
“-”,叫【连接号】(英文短的),属于英文专用的,叫“hyphen”
◆“_”是下划线,英文就是:underline
+ plus 加号;正号
- minus 减号;负号
± plus or minus 正负号
× is multiplied by 乘号
÷ is divided by 除号
= is equal to 等于号
≠ is not equal to 不等于号
≡ is equivalent to 全等于号
≌ is equal to or approximately equal to 等于或约等于号
≈ is approximately equal to 约等于号
< is less than 小于号
> is more than 大于号
≮ is not less than 不小于号
≯ is not more than 不大于号
≤ is less than or equal to 小于或等于号
≥ is more than or equal to 大于或等于号
% per cent 百分之...
‰ per mill 千分之...
∞ infinity 无限大号
∝ varies as 与...成比例
√ (square) root 平方根
∵ since; because 因为
∴ hence 所以
∷ equals, as (proportion) 等于,成比例
∠ angle 角
⌒semicircle半圆
⊙ circle 圆
○ circumference 圆周
π pi 圆周率
△ triangle 三角形
⊥ perpendicular to 垂直于
∪ union of 并,合集
∩ intersection of 交,通集
∫ the integral of ...的积分
∑ (sigma) summation of 总和
° degree 度
′ minute 分
″ second 秒
℃ Celsius system 摄氏度
{ open brace, open curly 左花括号
} close brace, close curly 右花括号
( openparenthesis, open paren 左圆括号
) close parenthesis, close paren 右圆括号
() brakets/ parentheses 括号
[ open bracket 左方括号
] close bracket 右方括号
[] square brackets 方括号
. period, dot 句号,点
| vertical bar, vertical virgule 竖线
&ersand, and, reference, ref 和,引用
* asterisk, multiply, star, pointer 星号,乘号,星,指针
/ slash, divide, oblique 斜线,斜杠,除号
// slash-slash, comment 双斜线,注释符
# pound 井号
\backslash, sometimes
escape 反斜线转义符,有时表示转义符或续行符
~tilde波浪符
. full stop 句号
, comma 逗号
: colon 冒号
; semicolon 分号
? question mark 问号
! exclamation mark (英式英语) exclamation point (美式英语)
‘apostrophe撇号
- hyphen 连字号
-- dash 破折号
... dots/ ellipsis 省略号
" single quotation marks 单引号
"" double quotation marks 双引号
‖ parallel 双线号
& ampersand = and
~swungdash 代字号
§ section; division 分节号
→ arrow 箭号;参见号
Operator override.
Index qi 索引器allowed the objects to be indexed with array or collection.
接下来,书上开始一个个讲了
方法声明,方法调用会了。
public double ToBeHappy(double cost){
double left=cost;
left-=EatingKFC();
left-=BuyADress();
left-=ReadingBooks();
left-=DoSports();
return left;
}
一个我面试别人可能会考到的呢~值传递还是引用传递参数。
duang !Core section:给方法传递参数
参数可以通过引用或者通过值传递给方法。
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/68516.html