摘要:
1. 可空类型修饰符(?):引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空。例如:string str=null; 是正确的,int i=null; 编译器就会报错。为了使值类型也可为空,就可以使用可空类型,即用可空类型修饰符"?"来表示,表现形式为"T?"例如:int? 表示可 阅读全文
posted @ 2020-05-11 15:47
小寒2020
阅读(417)
评论(0)
推荐(0)
摘要:
例如: public static IConfigurationSection GetSection(this string configName, string path, string configDir = null) { string configFile = configName.GetC 阅读全文
posted @ 2020-05-11 15:38
小寒2020
阅读(4128)
评论(0)
推荐(2)
摘要:
C#中 ref 关键字的认识和理解 之前接手老项目的时候有遇到一些的方法参数中使用了ref关键字加在传参的参数前面的情况。对于新手,这里介绍和讲解一下ref的用法和实际效果。 CLR中默认所有方法的参数传递方式都是传值,也就是说不管你传递的对象是值类型还是引用类型,在作为参数传入到方法中时,传递的是 阅读全文
posted @ 2020-05-11 10:51
小寒2020
阅读(3557)
评论(0)
推荐(1)
摘要:
我的代码是: //读取 private void button1_Click(object sender, EventArgs e) { if(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory+"123.txt") != "") { thi 阅读全文
posted @ 2020-05-11 10:19
小寒2020
阅读(234)
评论(0)
推荐(0)
摘要:
将两个路径合成一个路径,自动处理路径分隔符的问题。 函数声明如下:public static string Combine ( string path1, string path2 ) 常规使用方法。string path = Path.Combine("D:\\work", "April.txt" 阅读全文
posted @ 2020-05-11 10:14
小寒2020
阅读(412)
评论(0)
推荐(0)

浙公网安备 33010602011771号