int num = Convert.ToInt32(Console.ReadLine());
// Console.ReadLine()只接收字符串格式的数据
位运算符
internal访问修饰符:带有internal访问修饰符的任何成员可以被定义在该成员所定义的应用程序内的任何类或方法访问。
可空类型==?==
int i1 // 默认值为0
int? i2 // 默认值为null
合并运算符==??==
如果第一个操作数的值为 null,则运算符返回第二个操作数的值,否则返回第一个操作数的值。
结构类型Struct与类的区别
类的默认访问修饰符是internal
析构函数用于在程序结束之前释放资源,析构函数不能继承或重载,可以理解为java中finally关键字在try-catch中的作用
派生类(派生类:基类)
using System;
namespace InheritanceApplication
{class Shape {public void setWidth(int w){width = w;}public void setHeight(int h){height = h;}protected int width;protected int height;}// 派生类class Rectangle: Shape{public int getArea(){ return (width * height); }}class RectangleTester{static void Main(string[] args){Rectangle Rect = new Rectangle();Rect.setWidth(5);Rect.setHeight(7);// 打印对象的面积Console.WriteLine("总面积: {0}", Area());Console.ReadKey();}}
}
动态多态性(通过抽象类和虚方法实现)
通过在类定义前面放置关键字sealed,可以将类声明为密封类,即不能被继承,所以抽象类不能声明为密封类
virtual和abstract实际的开发场景是什么?
1.virtual修饰的方法必须有实现(哪怕是仅仅添加一对大括号),而abstract修饰的方法一定不能实现。
2.virtual可以被子类重写,而abstract必须被子类重写。
3.如果类成员被abstract修饰,则该类前必须添加abstract,因为只有抽象类才可以有抽象方法。
4.无法创建abstract类的实例,只能被继承无法实例化。
预处理器指令
输入输出流知识点
委托和事件
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _001_初识Csharp
{class Program{// 注册委托public delegate void OrderDelegate();static void Main(string[] args){// 实例化委托OrderDelegate od = new OrderDelegate(Order.BuyFood);// 多播委托od += Order.BuyCake;od += Order.BuyFlower;od(); // 调用委托}}class Order {public static void BuyFood() {Console.WriteLine("购买食物");}public static void BuyCake(){Console.WriteLine("购买蛋糕");}public static void BuyFlower(){Console.WriteLine("购买鲜花");}}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _001_初识Csharp
{class Program{// 注册委托public delegate void AreaDelegate(double length,double width);static void Main(string[] args){Console.WriteLine("请输入长方形的长!");double length = double.Parse(Console.ReadLine());Console.WriteLine("请输入长方形的宽!");double width = double.Parse(Console.ReadLine());AreaDelegate areaDelegate = delegate {Console.WriteLine("长方形的面积为:"+length*width);};areaDelegate(length,width);}}}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace _001_初识Csharp
{// 实例化类=>实例化事件=>触发事件=>事件调用委托=>委托调用委托中的方法class Program{// 注册委托public delegate void SayDelegate();// 注册事件public event SayDelegate SayEvent;// 定义委托中调用的方法public void SayHello() {Console.WriteLine("Hello");}// 创建触发事件的方法public void SayEventTrigger() {SayEvent(); // 这里必须和事件同名}static void Main(string[] args){// 实例化事件需要使用类的实例的事件指向委托(委托中需要传入委托方法)// 创建Program类的实例Program program = new Program();// 实例化事件,使用委托指向处理方法program.SayEvent = new SayDelegate(program.SayHello);// 调用触发事件的方法program.SayEventTrigger();}}}
UIA主要有4个DLL:
关系如下图所示:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-brOK6Tet-1625024519301)(.gif)]
2021/6/29遗留问题:TreeWalker、user32.dll
本文发布于:2024-01-29 05:51:02,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170647866713154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |