随笔分类 -  C#

Unity 开坑学习C#
摘要:C# 使用IComparer自定义List类的排序方案 List类中不带参数的Sort函数可以用来为List类中的元素排序,但如果List类中的元素类型本身不能直接进行比较(如自定义的struct和很多class),或是希望采用更加灵活的自定义比较方式,可以通过继承了IComparer接口的函数来解 阅读全文
posted @ 2020-09-16 22:45 想活出点人样 阅读(161) 评论(0) 推荐(0)
摘要:Sort的IComparer我不会设置,以后的再搞。。。QAQ 1 using System; 2 using System.Collections; 3 4 namespace C_9_4 5 { 6 7 class Program 8 { 9 10 private static void Put 阅读全文
posted @ 2020-09-16 22:44 想活出点人样 阅读(264) 评论(0) 推荐(0)
摘要:LastIndexOf花了很长的时间才试出来是怎么回事,,, 有点长了,,, 1 using System; 2 using System.Collections; 3 4 namespace C_9_4 5 { 6 class Program 7 { 8 private static void t 阅读全文
posted @ 2020-09-15 22:52 想活出点人样 阅读(180) 评论(0) 推荐(0)
摘要:1 using System; 2 using System.Collections; 3 4 namespace C_9_4 5 { 6 class Program 7 { 8 private static void test_1(ArrayList b) 9 { 10 int i; 11 if 阅读全文
posted @ 2020-09-15 15:45 想活出点人样 阅读(292) 评论(0) 推荐(0)
摘要:CopyTo讲了三种方法 所以篇幅可能会比较长 1 static void Main(string[] args) 2 { 3 //ArrayList方法 4 5 //Add 6 //将对象添加到ArrayList的结尾处 7 int i, j, k; 8 ArrayList a = new Arr 阅读全文
posted @ 2020-09-12 15:11 想活出点人样 阅读(331) 评论(0) 推荐(0)
摘要:1 using System; 2 using System.Collections; 3 4 namespace C_9_4 5 { 6 class Program 7 { 8 9 static void Main(string[] args) 10 { 11 //ArrayList类 12 // 阅读全文
posted @ 2020-09-11 16:19 想活出点人样 阅读(776) 评论(0) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 //Array.Find 4 //搜索与指定条件match相匹配的项,然后输出第一个匹配项 5 //Array.Find(Array1,match); 6 7 int i, j, k; 8 int[] a = new i 阅读全文
posted @ 2020-09-11 15:03 想活出点人样 阅读(657) 评论(0) 推荐(0)
摘要:有点多,试了很久才试出来的。 static void Main(string[] args) { //Array抽象基类或者叫抽象父类的学习 //Array 的类因为是抽象的,所以他是不能创建对象 //即Array a = new Array();这样写是错误的。 //但是他的派生类是可以创建对象的 阅读全文
posted @ 2020-09-08 22:49 想活出点人样 阅读(217) 评论(0) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 //交错数组 4 //简单来说,就是建立一个每个维度长度不同的多维数组 5 int[][] aa = new int[3][]; 6 //这样我们就建立了一个交错数组 7 //有三层,而这三层的每一层都是没有定义长度的, 阅读全文
posted @ 2020-09-07 22:34 想活出点人样 阅读(460) 评论(0) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 //一维数组的两种初始化 4 //动态初始化 5 int a = 5; 6 int[] aa = new int[10]; 7 int[] bb = new int[a]; 8 //利用new给int数组在堆中开空间初始 阅读全文
posted @ 2020-09-07 16:08 想活出点人样 阅读(442) 评论(0) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 int i = 0; 4 string a = "我,是,傻,逼"; 5 string b = "我,是。大;傻‘逼s"; 6 string[] bb = new string[10]; 7 //存储被分割字符串的字符串 阅读全文
posted @ 2020-09-06 19:45 想活出点人样 阅读(448) 评论(2) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 //格式化字符串Format 4 String a = "我是傻逼"; 5 String b = "WSSB"; 6 char c = '是'; 7 char d = 'B'; 8 String.Format("a={0 阅读全文
posted @ 2020-09-06 16:36 想活出点人样 阅读(677) 评论(0) 推荐(0)
摘要:C#格式化字符串 数值型格式化结果表(格式化字符串) 字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 string.Format("{0:D3}", 2) 002 E 科学计数法 1.20E+001 1.20E+001 G 常规 st 阅读全文
posted @ 2020-09-06 16:35 想活出点人样 阅读(166) 评论(0) 推荐(0)
摘要:IndexOf使用方法 1 static void Main(string[] args) 2 { 3 string a, b; 4 char aa = 'D'; 5 char bb = '5'; 6 a ="SB"; 7 b = "SBDX"; 8 /* 9 这里的IndexOf是求子串的位置,而 阅读全文
posted @ 2020-09-06 15:55 想活出点人样 阅读(284) 评论(0) 推荐(0)
摘要:9.6非静态和静态方法 1 namespace C_9_4 2 { 3 class Program 4 { 5 6 //类型声明应放在main函数前面 7 static void Main(string[] args) 8 { 9 string a, b,c,d; 10 int an; 11 a = 阅读全文
posted @ 2020-09-06 15:36 想活出点人样 阅读(2670) 评论(0) 推荐(0)
摘要:Barney //搬运:https://www.cnblogs.com/zhxhdean/archive/2011/04/21/2023250.html c#静态方法和非静态方法区别 C#的类中可以包含两种方法:C#静态方法与非静态方法。那么他们的定义有什么不同呢?他们在使用上会有什么不同呢?让我们 阅读全文
posted @ 2020-09-06 14:34 想活出点人样 阅读(2142) 评论(0) 推荐(0)
摘要:1 using System; 2 3 namespace C_9_4 4 { 5 class Program 6 { 7 8 //类型声明应放在main函数前面 9 static void Main(string[] args) 10 { 11 //String.Compare比较顺序,AaBbC 阅读全文
posted @ 2020-09-06 10:50 想活出点人样 阅读(634) 评论(0) 推荐(0)
摘要:1 static void Main(string[] args) 2 { 3 unchecked 4 { 5 int i; 6 i = int.MaxValue + 10; 7 Console.WriteLine("溢出的i={0}",i); 8 //或者写成 9 //Console.WriteL 阅读全文
posted @ 2020-09-06 09:38 想活出点人样 阅读(194) 评论(0) 推荐(0)
摘要:1 using System; 2 3 namespace C_9_4 4 { 5 class Program 6 { 7 enum Gun {AK47=5,M4A1,M16=1,UZI,SB} 8 //类型声明应放在main函数前面 9 static void Main(string[] args 阅读全文
posted @ 2020-09-05 16:15 想活出点人样 阅读(208) 评论(0) 推荐(0)
摘要:1 using System; 2 3 namespace C_9_4 4 { 5 class Program 6 { 7 struct Student 8 { 9 public int xuehao; 10 public string banji; 11 public string name; 1 阅读全文
posted @ 2020-09-05 15:22 想活出点人样 阅读(191) 评论(0) 推荐(0)