- 博客(9)
- 资源 (5)
- 收藏
- 关注
原创 Newtonsoft.Json 把对象转换成json字符串
var resultJson = new{ records = rowCount, page = pageindex, //总页数=(总页数+页大小-1)/页大小 total = (rowCount + pagesize - 1) / pagesize,//总页数 rows = data.ToList<Web.Entity.Db.Table1Bean>(),}; //Newtonsoft.Json 把对象转换成json字符串string jso.
2020-07-19 19:31:04
870
原创 Twitter的snowflake解决了能够按照时间生成有序且不重复的全局唯一ID
public class IdWorker{ //机器ID private static long workerId; private static long twepoch = 687888001020L; //唯一时间,这是一个避免重复的随机量,自行设定不要大于当前时间戳 private static long sequence = 0L; private static int workerIdBits = 4; //机器码字节数。4个字节用来保存机器码(定义.
2020-07-19 18:51:36
444
转载 使用newtonsoft 解析json字符串(将json字符串转换成json对象)
首先将newtonsoft 引用到工程中解析json字符串有两种格式:(1)一种是单一的json字符串,如:{"a" : "aa", "b" : "bb"}单一的一条json字符串,则采用如下方法:string jsonText = @"{""input"" : ""value"", ""output"" : ""result""}";JObject jsonObj = JObject.Parse(jsonText);string input = jsonObj["input"]..
2020-07-19 15:03:37
3967
原创 WPF ListView实时更新及INotifyPropertyChanged使用演示
1、ListView要实现实时更新必须要有几个条件:(1)需要将List集合定义为ObservableCollection类型,改类型需要引用System.Collections.ObjectModel命名空间。(2)实体类需要继承INotifyPropertyChanged接口MainVindow.xaml.cs:using System;using System.Collections.Generic;using System.Collections.ObjectModel;us
2020-06-17 00:42:14
1681
转载 WPFDataGrid隐藏表头
<DataGrid x:Name="grid1" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="22,60,0,0" HeadersVisibility="None" VerticalAlignment="Top" Height="136" Width="1326" ItemsSource="{Binding}">要设置DataGrid表头隐藏,在XAML中添加HeadersVisibility="Non.
2020-06-14 22:42:20
1425
原创 C#委托简单测试
<Grid Margin="10"> <TextBlock Text="测试委托前的内容" x:Name="NameWeiTuo"></TextBlock> <Button Content="执行委托" Width="100" Height="100" Click="Button_Click"></Button> </Grid>public partial class MainWin...
2020-06-08 00:55:35
182
原创 WPF+INotifyPropertyChanged+SerialPort串口调试
1、WPF前端控件绑定属性<Grid> <StackPanel Orientation="Vertical" Margin="20"> <StackPanel Orientation="Horizontal"> <TextBlock Text="重量:" FontSize="40"></TextBlock> <
2020-06-08 00:10:43
325
原创 SQL Server 将 varchar 转换为数据类型 numeric 时出现算术溢出错误,问题排查
今天遇到:将 varchar 转换为数据类型 numeric 时出现算术溢出错误。经排查发现,数据库设计的字段的类型为decimal,长度为4,小数位为2。需要写入的值为100,就会报溢出错误。实际上原因是:100在decimal类中存储时真正值为:100.00,长度为5。而字段长度定义为4,就溢出了。也就是说设计数据库字段时,长度是包含小数位的,这是一个低级错误。...
2020-03-06 23:39:17
19335
1
转载 winform打印问题时,如何去掉"正在打印"提示窗口
pdoc.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pdoc.Print();这里我想去掉 "正在打印" 小提示窗口 我因该怎样写? 谢谢 解决方案 »pdoc.PrintPage += new PrintPageEventHandler(this.ReceiptPrintPage); Sta...
2020-02-16 23:05:36
735
DelegateTest2.rar
2020-06-23
WPF ListView实时更新.rar
2020-06-17
SerialPortTest.rar
2020-06-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人