
C#
李建军
这个作者很懒,什么都没留下…
展开
-
c# CSV 笔记
csv读取FileStream fs = new FileStream("目录.csv", System.IO.FileMode.Open, System.IO.FileAccess.Read); StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default); string strline = sr.ReadLine(); string[] split =原创 2023-10-20 10:10:11 · 149 阅读 · 0 评论 -
c# Contains方法-检查集合中是否包含指定的元素
是 .NET 集合框架中许多集合类(如 List、Array、HashSet 等)提供的一种方法,用于检查集合中是否包含指定的元素。方法会遍历列表中的所有元素,并判断传入的方法参数是否存在于这个列表中。如果不保证一定能转换成功,可以考虑在调用。这样,你就避免了多次比较,直接检查。的整数值是否在列表中。原创 2024-02-20 18:19:11 · 4237 阅读 · 0 评论 -
C# 字典(Dictionary)基本操作
注意:在字典中,键是唯一的,不能有重复的键;同时,字典内部通常采用哈希表实现,因此查找、添加和删除操作的时间复杂度通常是O(1)。九、C# 8.0 及以上版本还引入了。原创 2024-02-19 17:37:51 · 4318 阅读 · 0 评论 -
using Aspose文档合并总结
using Aspose.Words;//word文档合并Document doc1 = new Document(d1); Document doc2 = new Document(d2); Document doc3 = new Document(d3); doc1.AppendDocument(doc2,...原创 2022-05-14 18:08:59 · 356 阅读 · 0 评论 -
c# 链接mdb读写代码
c# 链接mdb读写代码原创 2022-02-07 23:33:45 · 646 阅读 · 0 评论 -
c# 条件运算符
int saleAmount = 1001;int discount = saleAmount > 1000 ? 100 : 50;Console.WriteLine($"Discount: {discount}");Discount: 100条件运算符?:(通常称为三元条件运算符)用于计算布尔表达式,并返回两个表达式中其中一个的计算结果,返回的结果取决于布尔表达式的计算结果为 true 还是 false。其基本形式如下:<evaluate this conditio..原创 2021-10-07 23:50:13 · 385 阅读 · 0 评论 -
c#创建内插字符串
var item = (Name: "eggplant", Price: 1.99m, perPackage: 3);var date = DateTime.Now;Console.WriteLine($"On {date}, the price of {item.Name} was {item.Price} per {item.perPackage} items.");Console.WriteLine($"On {date:d}, the price of {item.Name} was.原创 2021-10-07 22:59:44 · 254 阅读 · 0 评论 -
Xamarin.Forms的布局
布局控件之StackLayout<StackLayout><StackLayout BackgroundColor="#A8A8A8"> <Label Text="布局1"/> </StackLayout></StackLayout>//嵌套StackLayout_1 ...原创 2020-03-15 12:31:40 · 339 阅读 · 0 评论 -
c# 操作符原理及概念
1操作符概览2操作符的本质操作符的本质是函数(即算法)的简记法static void Main(string[] args) { Person people1 = new Person(); Person people2 = new Person(); peo...原创 2020-03-15 12:30:20 · 263 阅读 · 0 评论 -
c# Intersect 交集,Except 差集,Union 并集
Intersect 交集,Except 差集,Union 并集int[] oldArray = { 1, 2, 3, 4, 5 };int[] newArray = { 2, 4, 5, 7, 8, 9 };var jiaoJi = oldArray.Intersect(newArray).ToList();//2,4,5var oldChaJi = oldArray.Except(ne...原创 2019-09-14 20:27:11 · 7268 阅读 · 1 评论 -
c# 目录文件夹去掉中文
核心思想如下 Regex reg = new Regex(@"[\u4e00-\u9fa5]");//正则表达式可以用来判断字符串中是否包含中文 str = reg.Replace(str, "");//将中文字符替换成空字段 destFolderPath = fsinfo.F...原创 2019-08-10 22:44:24 · 493 阅读 · 0 评论 -
C#中的List<string>泛型类示例
using System;using System.Collections.Generic;class Program{ static void Main() { List<string> cities = new List<string>(); // List of city names cities.Add("S...原创 2019-08-08 21:14:30 · 392 阅读 · 0 评论 -
c# 目录文件夹加前缀名
1 知识要点1.1 修改文件名称string srcFileName = @"D:/a.txt";string destFileName = @"D:/b.txt";if (System.IO.File.Exists(srcFileName)) { System.IO.File.Move(srcFileName, destFi...原创 2019-08-08 21:13:52 · 974 阅读 · 0 评论 -
c# word操作方法
1 打开word模板文档object objTrue = true; object oMissing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop...原创 2019-01-04 23:04:30 · 1385 阅读 · 0 评论 -
C# excel操作方法
1 打开指定excel Microsoft.Office.Interop.Excel.Application myExcel = new Microsoft.Office.Interop.Excel.Application();//引用Excel对象 Microsoft.Office.Interop.Excel.Workbook book = myExcel.Application.Wor...原创 2018-08-01 20:53:16 · 476 阅读 · 0 评论 -
C#选择文件或者选择文件夹
1 点击按钮选择文件 private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false;//该值确定是否可以选择多个文件 ...原创 2018-08-01 18:19:40 · 5536 阅读 · 1 评论