随笔分类 -  C#

vs2022 调试 dapr
摘要:基础环境: Windows 11 专业版 Microsoft Visual Studio Enterprise 2022 (64 位) - Preview 引用: 思路: https://github.com/dapr/dotnet-sdk/issues/401#issuecomment-74756 阅读全文

posted @ 2022-09-02 11:37 不会非的猪 阅读(412) 评论(0) 推荐(0) 编辑

记一次小型项目部署的问题(AspNetCore Api与 前端 一起部署到iis相同站点)
摘要:AspNetCore 与 前端页面 进行统一部署 1 app.UseStaticFiles();//开启静态文件 2 3 app.UseEndpoints(endpoints => 4 { 5 endpoints.MapGet("/",async context => 6 { 7 context.R 阅读全文

posted @ 2021-02-04 17:14 不会非的猪 阅读(192) 评论(0) 推荐(0) 编辑

开放封闭原则 Open-Closed Principle(OCP)
摘要:最理想的状态(或者目的)是软件中的对象(类,模块,函数等等)应该对于扩展是开放的,但是对于修改是封闭的。 1.栗子 2.如果需要增加一个新的日志方式(比如数据库,服务等),怎么办?当然这段代码也违背了单一职责原则。 3.如果以上述的方式进行设计,那么新的需求加入,即可如下实现。 参考:https:/ 阅读全文

posted @ 2019-07-18 16:21 不会非的猪 阅读(198) 评论(0) 推荐(0) 编辑

单一职责原则 Single Responsibility Principle(SRP)
摘要:最理想的状态(或者目的)是一个类应该做一件事或者只做一件事。 1.典型代码(Csv文件处理程序) 现在看上去好多了,但是依旧没有能达到目标(比如:如果文件不是Csv格式,亦或Xml?Json?等等),设计不够牢靠。 3.再次改进 阅读全文

posted @ 2019-07-18 15:42 不会非的猪 阅读(320) 评论(0) 推荐(0) 编辑

Windows.Devices API in a C# WinForm Win32 Desktop application in Windows 10
摘要:https://social.msdn.microsoft.com/Forums/windows/en-US/40b4f86d-b6d5-430e-a235-7fc003dec4c4/how-to-use-windowsdevicesgeolocation-api-in-a-c-winform-wi 阅读全文

posted @ 2018-12-10 15:13 不会非的猪 阅读(3413) 评论(0) 推荐(0) 编辑

随记181120Service Fabric问题
摘要:https://github.com/Azure/service-fabric-issues/issues/1056 不能启动node one /five 问题 阅读全文

posted @ 2018-11-20 16:02 不会非的猪 阅读(170) 评论(0) 推荐(0) 编辑

net core mysql 组件记录
摘要:nuget 下 Pomelo.EntityFrameworkCore.MySql (据说是微软官方推荐) MySql.Data.EntityFrameworkCore (甲骨文出品) 使用方式等同于 EntityFrameworkCore 阅读全文

posted @ 2018-05-25 17:20 不会非的猪 编辑

索引
摘要:1 class Program 2 { 3 4 static void Main() 5 { 6 var pair = new Pair<int>(10,12); 7 8 Console.WriteLine($"this is {pair.First} and {pair[PairItem.Seco 阅读全文

posted @ 2018-05-03 14:15 不会非的猪 编辑

IComparer 与 IComparable
摘要:1 static void Main() 2 { 3 var people = new ArrayList(); 4 people.AddRange(new ArrayList 5 { 6 new Person{ Name = "Jone",Age = 18}, 7 new Person{ Name 阅读全文

posted @ 2018-05-03 10:05 不会非的猪 编辑

foreach
摘要:有点意思!!! 阅读全文

posted @ 2018-05-02 11:22 不会非的猪 编辑

泛型
摘要:泛型约束小计: 1 class Program 2 { 3 static void Main(string[] args) 4 { 5 { 6 var generice = new GenericClass(); 7 8 generice.ShowInt(11); 9 generice.ShowDa 阅读全文

posted @ 2018-04-26 15:29 不会非的猪 编辑

枚举
摘要: 阅读全文

posted @ 2018-04-18 10:34 不会非的猪 阅读(114) 评论(0) 推荐(0) 编辑

装箱和拆箱
摘要:如何避免呢??? 1.合理的使用重载以及重写方法。 2.使用泛型 3.如果不可避免,显式的使用装箱。 阅读全文

posted @ 2018-04-17 17:11 不会非的猪 阅读(120) 评论(0) 推荐(0) 编辑

使用TryParse()来执行数值转换
摘要:static void Main() { var ageText = "25"; if (int.TryParse(ageText,out int age)) { Console.WriteLine("Hi,My age is {0}",age); ... 阅读全文

posted @ 2018-04-12 10:43 不会非的猪 编辑

参数数组
摘要:static void Main() { Console.WriteLine(Combine("test:\\", "abc", @"\def")); Console.WriteLine(Combine(new string[]{"abc"," def" ," g"})); Console.... 阅读全文

posted @ 2018-04-12 10:01 不会非的猪 编辑

checked和unchecked转换
摘要:static unsafe void Main(string[] args) { unchecked //checked 运行时候引发异常 { int n = int.MaxValue; n++; Console.Wri... 阅读全文

posted @ 2018-04-11 11:38 不会非的猪 阅读(170) 评论(0) 推荐(0) 编辑

字符串不可变
摘要:1 static unsafe void Main(string[] args) 2 { 3 //StringBuilder 可变 4 //string 每次修改都将产生一个新的字符串(不可变) 5 //*** 所以,对不修改的字符串使用string,否则使用StringBuild... 阅读全文

posted @ 2018-04-11 10:08 不会非的猪 编辑

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