第四天009
越往上优先级越高

加号操作符operator
main()
{
}
class Person
{
public string name;
public static List<Person> operator +(Person p1,Person p2)
{
List<Person> people=new List<Person>();
people.add(p1);
people.add(p2);
for(int i=0;i<10;i++)
{
Person child=new Person();
child.name=p1.name+"&"+p2.name+"母亲";
People.add(child);
}
return people;
}
}

用default获取枚举类型的值的时候要小心下标注0,假如标注好了顺序比如a=0 b=1......类推,后而第一个是a 第二是b 假如没有0那么default返回的是0不是值
new可以调用初始化器 比如: Form f=new Form(){Text=“哈哈哈”};<------相当于f.Text="哈哈哈";
animo a = new animo();
a.info();
shizi s = new shizi();
s.info();
}
}
class animo
{
public void info()
{
Console.WriteLine("我是哺乳动物");
}
}
class shizi:animo
{
new public void info()
{
Console.WriteLine("我是狮子");
}
}
这里的New是隐藏操作符不是new了 用于屏蔽父类的方法
check会去检测溢出 unchecked不会去检测(默认用的这个)
通过指针访问符号:->
public struct student
{
public int id;
public long score;
}
unsafe
{
student s;
s.id = 007;
s.score = 100;
student* Pstu = &s;
Console.WriteLine(Pstu->score);
}
(*pstu).score 这样才能获取到score 因为*操作符没有.操作符权限大所以不加括号是先运行的.
~~~取反符号
单独使用--和++不管是前置还是后置他都是正常执行,结果一样
后置--和++碰到=赋值运算符就是先算赋值,如果是前置就先算++或--
隐式转换:

Parse:只能够转换正确的
Convert:都能够
注意!!理解oprator

上面是double类型的表 double 乘以
左移乘2右移除2
左移<<符号是二进制偏移,左边偏移1位 用unchecked和checked的
右移>>
有条件与 条件或&&和||
下面是
^这个是异或符号 1和1为假 0和0为0 1和0为真
&和|
Nullable<int>就相当于int? 相当于可以给int赋一个null值
int? a=null;
int b=a??3; (意思就是如果这个值是null就给他赋予一个3的值)
:?条件操作符(相当于if else)
lambad操作符:


浙公网安备 33010602011771号