posts - 102,comments - 0,views - 35459
07 2023 档案
虚函数与抽象函数
摘要:虚函数是有代码的并明确允许子类去覆盖,但子类也可不覆盖,就是说可以直接用,不用重写 //虚方法,必须声明主体(默认方法体)可重写可不重写。 public class A { public virtual void a() { Console.WriteLine("虚函数a"); } public v 阅读全文
posted @ 2023-07-28 23:04 阿霖找BUG 阅读(13) 评论(0) 推荐(0) 编辑
.net事件
摘要:事件是委托的实例 三大特性订阅,触发,发布 学生,老师,学校三个类 学校有个方法叫上课倒计时,学生和老师订阅了这个方法,有一个事件叫上课铃,学生和老师有个方法叫上课去了。 学生和老师的“上课去了”方法注册到“上课”事件中。当学校倒计时结束调用这个事件,发布上课消息,学生和老师收到就会触发“上课去了” 阅读全文
posted @ 2023-07-28 22:46 阿霖找BUG 阅读(67) 评论(0) 推荐(0) 编辑
求最大公约数
摘要:8与7之间的公约数 15/7=2.....1 7/1=7....0 公约数是1 public static int Gmc(int a, int b) { int tmpe=0; while (b != 0) { tmpe = a % b; a = b; b = tmpe; } return a; 阅读全文
posted @ 2023-07-26 23:39 阿霖找BUG 阅读(7) 评论(0) 推荐(0) 编辑
线程
摘要:public static void CallToChildThread() { try { Console.WriteLine("执行子程序"); int sleepfor = 5000; Thread.Sleep(sleepfor); Console.WriteLine($"暂停{sleepfo 阅读全文
posted @ 2023-07-24 23:20 阿霖找BUG 阅读(6) 评论(0) 推荐(0) 编辑
冒泡
摘要:static void Main(string[] args) { // int[] a=new int[]{1,1,4,6,10}; for(int i=0;i<a.Length;i++){ for(int j=i+1;j<a.Length;j++){ if(a[i]>a[j]){ int tmp 阅读全文
posted @ 2023-07-20 17:53 阿霖找BUG 阅读(4) 评论(0) 推荐(0) 编辑
枚举
摘要:public enum Sea { id, age, name } Sea s = Sea.age; Sea s1 = Sea.id; var s2 = (Sea)2;//name Console.WriteLine($"{s},{(int)s},{(int)s1},{s2}");//age,1,0 阅读全文
posted @ 2023-07-17 09:39 阿霖找BUG 阅读(9) 评论(0) 推荐(0) 编辑
LINQ和lambda表达式
摘要:LINQ: select结尾,from开头(from->where->groupby->having->orderby->join->select) var tt = from aa in cd select aa.Count();//查询一个值就不用数组 连接数组,join in放在select前 阅读全文
posted @ 2023-07-15 18:29 阿霖找BUG 阅读(22) 评论(0) 推荐(0) 编辑
C#中数组嵌套数组
摘要:public class mo { public int q1 { get; set; } public int count { get; set; } } class Class1 { static void Main(string[] args) { int[] a = new int[] { 阅读全文
posted @ 2023-07-15 17:10 阿霖找BUG 阅读(368) 评论(0) 推荐(0) 编辑
C#函数设定默认参数
摘要:传入的值为null static string[] Result2(string p1, string p2="2") { string[] s = new string[] { p1, p2 }; return s; } public string[] Result(string p1, stri 阅读全文
posted @ 2023-07-15 14:45 阿霖找BUG 阅读(291) 评论(0) 推荐(0) 编辑
textbox多行输入
摘要:下 MultiLine打勾; 代码: foreach(int a in nums) { textBox1.AppendText($"p1:{p1};p2:{p2};{a}"); textBox1.AppendText(System.Environment.NewLine);//下一行 } 阅读全文
posted @ 2023-07-15 10:19 阿霖找BUG 阅读(50) 评论(0) 推荐(0) 编辑
在集合中加入随机的数字(1-20)
摘要:public void nums() { ArrayList list = new ArrayList(); Random r = new Random(); list.Add(r.Next(20)); while (true) { if (list.Count == 20) break; int 阅读全文
posted @ 2023-07-13 18:13 阿霖找BUG 阅读(16) 评论(0) 推荐(0) 编辑
base
摘要:子类继承父类,重写父类,在子类中调用父类被覆盖的方法。 public class Person { public virtual void GetInfo()//要标明是什么函数;virtual虚函数 { Console.WriteLine("qqqqqqqe"); } } class Employ 阅读全文
posted @ 2023-07-13 14:48 阿霖找BUG 阅读(19) 评论(0) 推荐(0) 编辑
委托
摘要:Action无返回值 Action<string> greet = name =>//无返回值所以Action<输入类型> { string greeting = $"Hello {name}!"; Console.WriteLine(greeting); }; greet("World");//调 阅读全文
posted @ 2023-07-13 11:00 阿霖找BUG 阅读(7) 评论(0) 推荐(0) 编辑
随机洗牌
摘要:private static void sum(int[] nums) { Random rnd = new Random(); for(int i=nums.Length-1; i>=0; i--) { int a= rnd.Next(i + 1); //Console.WriteLine(a); 阅读全文
posted @ 2023-07-04 23:44 阿霖找BUG 阅读(6) 评论(0) 推荐(0) 编辑
委托
摘要:委托是对某个方法的引用的引用变量,引用在运行时可以被改变。 委托用于事件,和回调函数 继承于delegate类 事件是委托的实例,是一种特殊的委托。事件比委托安全。 委托先声明后实例化(new) 阅读全文
posted @ 2023-07-03 19:20 阿霖找BUG 阅读(12) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示