抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

C#对MongoDB增删改查以及MongoDB Atlas使用

简介MongoDB 是一个不同于 MySQL、SQL Server 等传统关系型数据库的面向文档的数据库管理系统,它是由 C++ 语言编写,基于分布式文件存储,为 WEB 应用提供了可扩展的高性能数据存储解决方案。 MongoDB 将数据存储为一个文档,数据结构由键值(key=>value)对组成。MongoDB 文档类似于 JSON 对象。字段值可以包含其他文档,数组及文档数组。 &...

C#中的switch判断范围值

从 C# 7.0 开始,因为 case 语句不需要互相排斥,因此可以添加 when 子句来指定必须满足的附加条件使 case 语句计算为 true。 when 子句可以是返回布尔值的任何表达式。 switch (totalPrice) { case decimal n when n <= 100: return 0; case decimal n when n...

C#中的问号语法糖

可空类型修饰符(?)引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空。例如:string str=null; 是正确的,int i=null; 编译器就会报错。为了使值类型也可为空,就可以使用可空类型,即用可空类型修饰符 “?“ 来表示,表现形式为 “T?”例如:int? 表示可空的整形,DateTime? 表示可为空的时间。 T? 其实是 System.Nulla...

C#的string.Format含有花括号

比如: string s = string.Format("{\"id\"=\"{0}\"}, \"name\"=\"{1}\"}", id, name); 这样的格式会报错。 解决办法: string s = string...

C#表示Char空值的方法

char c1 = '\0'; char c2 = Char.MinValue; char c3 = (char) 0; char c4 = Convert.ToChar(0); char c5 = ((char?) null).GetValueOrDefault(); char c6 = default(char); Console.WriteLine("Char...

C#遍历类对象获取属性名、值、Description

声明对象using System; using System.ComponentModel; using System.Reflection; [Description("用户")] public class User { [Description("编号")] public int Id { get; set; ...

C#的foreach执行多个actions

userList.ForEach(a => { a.Country = "China"; a.Currency = "RMB"; a.Area = "Asia"; });

C#判断文件名称是否有效

判断文件名称是否有效 var fileName = @"D:\Source\*Http:Server?.cs"; if (fileName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) != -1) { Console.WriteLine("File name is invalid&q...

C#枚举中添加特殊字符的方法

C# 声明枚举对象public enum EnumFileCategory { [Description("goods_files/pdf")] Pdf, PdfImg, [Description("My/image")] MyImg, [Description("My/video&q...

c#的stringFormat含有花括号

C# string.Format 中含有花括号 比如: string s = string.Format("{\"id\"=\"{0}\"}, \"name\"=\"{1}\"}", id, name); 这样的格式会报错,...