
C#
整理一下C#的学习笔记
我也秃了
全栈工程师转职魔法吟唱大法师
展开
-
Git单独文件退回版本
git log 文件全路径获取该文件的最近几次更新记录选择想要退回的版本记录commit ID 即commit 后面的那串代码(commit 和 括号分支名之间)然后git checkout commitID 文件全路径就会告诉你修改情况然后上传更新分支就可以了如果帮助到你,能点个赞吗?...原创 2022-03-10 11:08:55 · 362 阅读 · 0 评论 -
C# dataTable 设置主键
DataTable dt = new DataTable();....//有几个主键就设置多长DataColumn[] PrimaryKeyColumns = new DataColumn[2];//添加主键,必须是已经在DataTable里有的列名PrimaryKeyColumns[0] = dt.Columns["UserName"];PrimaryKeyColumns[1] = dt.Columns["UserId"];//配置主键dt.PrimaryKey = PrimaryKeyC原创 2022-02-18 09:28:39 · 3968 阅读 · 1 评论 -
GridView 设置内容自动换行显示
相应column 设置ColumnEdit 为 MemoEditGridView 属性 设置 OptionsView 的 RowAutoHeight 为True原创 2022-02-16 10:48:05 · 2110 阅读 · 0 评论 -
C# “Method ‘Create‘ does not have an implementation.解决思路
全部保错System.TypeLoadException:“Method ‘Create’ in type ‘Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlTranslatingExpressionVisitorFactory’ from assembly ‘Microsoft.EntityFrameworkCore.SqlServer, Version=3.1.21.0, Culture=neutral, Publi原创 2021-12-07 10:53:37 · 2439 阅读 · 0 评论 -
Enumerator failed to MoveNextAsync 处理思路
之前的写法public async Task<myMap> GetMapAsync( string CompanyId, string specs) { ICollection<myMap> result = _fcpDbContext.myMaps .Where(item => item.CompanyId== CompanyId) .AsNoTr原创 2021-08-19 16:08:36 · 1210 阅读 · 0 评论 -
C#根据字符串内容读取Object属性的值
首先随便哪一个类举例子 public class User { .... public string name {get;set;} public string phone {get;set;} public string adress {get;set;} }然后在实例化之后,使用matchcolumn指定需要读取的属性User user = new User()...string matchcolumn = 'name';string name原创 2021-05-20 15:59:13 · 1090 阅读 · 0 评论 -
C# 关闭指定EXCEL(进程)kill the certain Excel process
Today, I was asked to kill the excel process which opened by other program.Since I can not change that program, I have to do some improvement in my code.At first, it is really difficult for me to search a good way to kill the process,but I was fortunate原创 2021-03-03 15:42:31 · 1220 阅读 · 2 评论 -
C# switch的全新版本
C# switch 新用法C#8.0 switch新用法模式和 case guardC#8.0 switch新用法在公司发现了类似return(String)switch{AName => new User(Repository, settings),BName => new User2(Repository, settings),_ => throw new ArgumentException(…),}这种用法,以作记录模式和 case guardswitch expre原创 2020-05-15 11:07:24 · 4831 阅读 · 0 评论 -
C# Class学习
Please give me a like before reading !!!sample:using System;using System.Linq;namespace HelloWorld{ public class Person { // Constructor that takes no arguments: public Person() { Name = "unknown";原创 2020-09-03 11:32:36 · 342 阅读 · 0 评论 -
C#后端学习(一) API返回mock数据
Mock 数据是前端开发过程中必不可少的一环,是分离前后端开发的关键链路。通过预先跟服务器端约定好的接口,模拟请求数据甚至逻辑,能够让前端开发独立自主,不会被服务端的开发所阻塞。写一个简单的例子 [HttpPost] public ActionResult<IEnumerable<Product>> searchProduct() { string mockData; //字符串用 ""包裹,数字不用原创 2020-11-17 14:19:12 · 1014 阅读 · 0 评论 -
.NET Hexagonal Architecture 学习笔记
原文原创 2020-10-24 11:54:48 · 451 阅读 · 1 评论 -
C# 获取当前周的周一和周五
DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))); //本周周一 DateTime endWeek = startWeek.AddDays(4); //本周周五 (后移四天)//今天周五Console.WriteLine(dt.DayOfWeek)//FridayConsole.WriteLine(dt.原创 2020-09-04 16:29:11 · 2317 阅读 · 1 评论 -
C# String 删除指定字符
yourstr.Replace("-", string.Empty)//比如删除'-'原创 2020-09-04 13:46:52 · 5177 阅读 · 0 评论