随笔分类 -  C#

leaning C#
摘要:internal class Program { const string Item = "Dictionary item"; const int Iterations = 1000000; public static string CurrentItem; static void Main(str 阅读全文
posted @ 2024-02-29 23:01 JohnYang819 阅读(76) 评论(0) 推荐(0) 编辑
摘要:cshtml一般是这样: @page @model IndexModel @{ ViewData["Title"] = "Home page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <p>Learn about 阅读全文
posted @ 2024-01-21 10:55 JohnYang819 阅读(81) 评论(0) 推荐(0) 编辑
摘要:install-package WindowsAPICodePack var folderDialog = new CommonOpenFileDialog() { Title = "xxx", IsFolderPicker = true, }; if (folderDialog.ShowDialo 阅读全文
posted @ 2024-01-16 21:44 JohnYang819 阅读(200) 评论(0) 推荐(0) 编辑
摘要:字符串的存储长度是可变的,在C#中,BinaryWriter和BinaryReader在Write,ReadStirng的时候,都在单个流中字符串的二进制数组前面加了一个二进制数组的长度信息,方便读取的时候,造成了记录字符串的流并不纯粹是字符串的内容。但是,有时候,我们可以,也可能必须记录纯粹的字符 阅读全文
posted @ 2024-01-15 10:14 JohnYang819 阅读(12) 评论(0) 推荐(0) 编辑
摘要:(1)与关键字冲突,解决办法加@ var a = new { @class=1, }; var d = JsonConvert.SerializeObject(a); Console.WriteLine(d); output {"class":1} (2)接参数,dynamic神搭配! var a 阅读全文
posted @ 2024-01-12 19:20 JohnYang819 阅读(36) 评论(0) 推荐(0) 编辑
摘要:1.赋予参数 @page "{id}" @model RazorTest.Pages.TestBModel @{ } <p>TestBId is @Model.TestBId</p> using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore 阅读全文
posted @ 2024-01-02 13:55 JohnYang819 阅读(93) 评论(0) 推荐(0) 编辑
摘要:cshtml.cs using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace RazorTest.Pages { public class PrivacyModel : PageModel 阅读全文
posted @ 2024-01-01 11:12 JohnYang819 阅读(53) 评论(0) 推荐(0) 编辑
摘要:ASP.NET Core中路由的过程:routing middleware把传入的url与一系列模板进行比对,选择相应的endpoint handler,并将其记录在HttpContext上的request上。endpoint middleware执行选择的endpoint hander,并返回re 阅读全文
posted @ 2023-12-31 11:21 JohnYang819 阅读(31) 评论(0) 推荐(0) 编辑
摘要:1.状态码返回之演化之路 1.1最基本的就是用Results或者TypedResults返回带有状态码的响应(可选Json响应体) app.MapGet("/fruit/{id}", (string id) => { if (_fruit.TryGetValue(id, out Fruit frui 阅读全文
posted @ 2023-12-30 17:46 JohnYang819 阅读(208) 评论(0) 推荐(0) 编辑
摘要:<Button Width="100" Height="150"> <Button.Content> <TextBlock Text="简图库" TextAlignment="Center"> <TextBlock.LayoutTransform> <RotateTransform Angle="- 阅读全文
posted @ 2023-12-27 15:13 JohnYang819 阅读(91) 评论(0) 推荐(0) 编辑
摘要:INotifyCollectionChanged 接口是 System.Collections.Specialized 命名空间中的一个接口,用于在集合发生更改时通知订阅者。这个接口通常在实现了集合的类中使用,以便在集合变化时通知监听者(如 UI 控件)进行更新。 以下是 INotifyCollec 阅读全文
posted @ 2023-12-17 10:18 JohnYang819 阅读(464) 评论(0) 推荐(0) 编辑
摘要:<Window x:Class="GuiDB.EBMultiEditTextWin" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/win 阅读全文
posted @ 2023-12-14 14:07 JohnYang819 阅读(21) 评论(0) 推荐(0) 编辑
摘要:string content=""; GraphicsPath c1 = new GraphicsPath(); c1.AddEllipse(0, 20, 50, 50); GraphicsPath c2 = new GraphicsPath(); c2.AddEllipse(30, 20, 50, 阅读全文
posted @ 2023-11-19 21:23 JohnYang819 阅读(25) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Interop; using System.Windows.Med 阅读全文
posted @ 2023-11-13 13:07 JohnYang819 阅读(319) 评论(0) 推荐(0) 编辑
摘要:System.Text.Json 是 C# 中的一个 JSON 序列化和反序列化库,它在 .NET Core 3.0 及更高版本中提供了内置支持。以下是 System.Text.Json 的用法详解: JSON 序列化 JSON 序列化是将 .NET 对象转换为 JSON 字符串的过程。 using 阅读全文
posted @ 2023-10-25 13:22 JohnYang819 阅读(2537) 评论(0) 推荐(0) 编辑
摘要:ASP.NET Core已有数据库,却新建项目,只需要构造出相应的类,DbContext,然后直接add-migration init即可!!而不用执行update-database,执行后者会报错:Error Number:2714,State:6,Class:16 There is alread 阅读全文
posted @ 2023-10-25 13:08 JohnYang819 阅读(20) 评论(0) 推荐(0) 编辑
摘要:public interface IRepository<T> { void Add(T entity); List<T> Get(); } public class Repository<T> : IRepository<T> { List<T> _list = new List<T>(); pu 阅读全文
posted @ 2023-10-19 21:57 JohnYang819 阅读(122) 评论(0) 推荐(0) 编辑
摘要:在ASP.NET Core的依赖注入(DI)容器中,当你使用Add*方法和泛型类型来指定要注册的类时,容器会做出以下假设: (1)类必须是具体类(Concrete Class):使用Add*方法注册的类必须是一个具体的类,不能是接口或抽象类。这是因为你正在为特定服务类型注册一个实际的实现类。 (2) 阅读全文
posted @ 2023-10-19 13:34 JohnYang819 阅读(15) 评论(0) 推荐(0) 编辑
摘要:public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("/product/{name}", (s 阅读全文
posted @ 2023-10-16 13:08 JohnYang819 阅读(27) 评论(0) 推荐(0) 编辑

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