welcome to Qijie's Blog 薛其杰

随笔分类 -  .NET Framework

C# Main函数中调用异步方法的2种实现
摘要:As you discovered, in VS11 the compiler will disallow an async Main method. This was allowed (but never recommended) in VS2010 with the Async CTP. I h 阅读全文
posted @ 2019-03-12 11:01 零点零一 阅读(1895) 评论(0) 推荐(0)
Using Dispatcher
摘要:he following code example shows how you might attempt to update the UI from your task logic. // The Wrong Way to Update a UI Objectpublic void btnGetT 阅读全文
posted @ 2017-08-15 16:22 零点零一 阅读(142) 评论(0) 推荐(0)
C#修改json文件中的某些值
摘要:using Newtonsoft.Json; JsonSerializer serialiser = new JsonSerializer(); string newContent = string.Empty; using (StreamReader reader = new StreamReader(file.FullName)) ... 阅读全文
posted @ 2017-03-01 15:58 零点零一 阅读(3319) 评论(0) 推荐(0)
字幕文件处理(2) - 字幕文件格式转化
摘要:上一篇文章我们实现了整数与时间格式的互转,常见的字幕文件的格式有WebVTT, SRT, TTML, 有的系统要求我们提供VTT格式, 有的系统只支持TTML格式,我们字幕做完一个拿到的可能是SRT格式, 所以设计到将不同格式的字幕文件进行转换。 阅读全文
posted @ 2016-05-16 16:00 零点零一 阅读(3773) 评论(0) 推荐(0)
字幕文件处理(1) - 时间格式与整数格式互转
摘要:一个字幕文件一般包含两部分内容:时间索引和脚本内容。一般,常见的字幕文件格式有WebVTT, SRT和TTML。 编辑字幕文件就是对每一段字幕的时间索引或脚本内容进行编辑。也包括对字幕文件的格式进行转换,参考字幕文件处理(2) - 字幕文件格式转化。 阅读全文
posted @ 2016-05-16 15:31 零点零一 阅读(1046) 评论(0) 推荐(0)
将对象序列化,反序列化到XML
摘要:using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; using Windows.Storage; namespace ... 阅读全文
posted @ 2016-03-18 16:17 零点零一 阅读(369) 评论(0) 推荐(0)
Newtonsoft.Json 处理多态类型的反序列化
摘要:Newtonsoft.Json的序列化和反序列化很成熟也很好用, 最近在处理多态类型的反序列化中遇到了问题, 反序列化后只能到基类,而得不到也不能转换到子类。从网上查询了一番后,需要写一个创建类型的Converter, 下面我们一步一步来: 1. 首先说明类型的定义, 为了做这个实验,我定义了一个基 阅读全文
posted @ 2016-03-18 15:40 零点零一 阅读(10850) 评论(0) 推荐(4)
创建XML文档结构
摘要:static void CreateXML(string outputPath) { XmlDocument _xmlDoc = new XmlDocument(); string _xmlNode = @""; ... 阅读全文
posted @ 2014-06-18 12:34 零点零一 阅读(157) 评论(0) 推荐(0)
枚举和字符串转换
摘要:public static String convertToString(this Enum eff){ return Enum.GetName(eff.GetType(), eff);}public static EnumType converToEnum(this String enumValue) { return (EnumType) Enum.Parse(typeof(EnumType), enumValue);}post from : http://stackoverflow.com/questions/483794/convert-enum-to-string 阅读全文
posted @ 2014-03-17 16:34 零点零一 阅读(1493) 评论(0) 推荐(0)
String.Format 全汇总
摘要:C#格式化数值结果表字符说明示例输出C货币string.Format("{0:C3}", 2)$2.000D十进制string.Format("{0:D3}", 2)002E科学计数法1.20E+0011.20E+001G常规string.Format("{0:G}", 2)2N用分号隔开的数字string.Format("{0:N}", 250000)250,000.00X十六进制string.Format("{0:X000}", 12)Cstring.Format("{0:000. 阅读全文
posted @ 2013-12-29 14:08 零点零一 阅读(282) 评论(0) 推荐(0)
Send Mail using C# code
摘要:using System.Net.Mail; public class MailHelp { public static void Send(string subject, string body) { MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(); client.Port = 25; client.Host = "smtphost.mycompany.com... 阅读全文
posted @ 2013-10-23 10:15 零点零一 阅读(346) 评论(0) 推荐(0)
重载 Sort, ==, !=
摘要:class Items:IComparable { public string Item { get; set; } public string File { get; set; } public string IsScored { get; set; } public string Weight { get; set; } public int CompareTo(object obj) { if (obj is Items) { ... 阅读全文
posted @ 2013-03-18 16:46 零点零一 阅读(417) 评论(0) 推荐(0)
XML节点访问与更新
摘要:1. XML节点访问与更新.2. DataGridView, 把 string[] bind到DataGridView.3. 通过封装器, 做成List<StringValue>.usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Xml;usingSystem.IO;names 阅读全文
posted @ 2012-11-30 16:57 零点零一 阅读(594) 评论(0) 推荐(0)
connection string for Excel/Access 2010
摘要:Excel 2010 连接字符串case1:ConnectionString=string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource={0};ExtendedProperties='Excel8.0;HDR=Yes;IMEX=1'",ExcelPath);break;case2:ConnectionString=string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource={0};ExtendedProperties=' 阅读全文
posted @ 2012-01-13 15:17 零点零一 阅读(1726) 评论(0) 推荐(1)
读书笔记: 泛型 - CLR via C#
摘要:为什么泛型?面向对象的语言好处是使得程序员可以很方便地重用代码, 在面向对象中程序员可以写一个子类去继承自一个父类,写不同的程序能够重用以前的代码, 会减少很多代码的工作量。但是算法能不能重用呢? 答案是肯定的, CLR提供了一个算法重用的机制, 就是泛型。算法重用的例子, 参考List<T>类型, 在System.Collections.Generic中定义。泛型类型和继承我们使用两段代码来说明:Internal sealed class Node<T>{Public T m_data;Public Node<T> m_next;Public Node(T 阅读全文
posted @ 2011-07-30 10:34 零点零一 阅读(468) 评论(0) 推荐(0)
timer.elapsed里边调用button.click事件
摘要:在timer.elapsed里边调用button.click事件 悬赏分:5 - 解决时间:2010-8-10 11:19 提问者: 7788wangzi - 二级最佳答案 阅读全文
posted @ 2010-08-10 12:10 零点零一 阅读(530) 评论(0) 推荐(2)
从文本文件读取信息
摘要:你若想要程序获取用户信息,比如:名字, 登录名. 而这些信息有不是固定不变的, 你可以从文本文件中读取这些信息, 怎样从文本文件中读取信息, 用到了.net的System.IO命名空间, 具体如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--s... 阅读全文
posted @ 2010-01-12 10:26 零点零一 阅读(396) 评论(2) 推荐(0)
通过IP地址获得主机名
摘要:如果你遇到这样的场景, 你知道远程机器的ip地址, 想要通过ip地址来获得主机名。可以使用.net的System.Net命名空间, 这里边有一个类是IPHostEntry, 使用方式如下:[代码]若是通过主机名获得IP地址也是使用此类.[代码] 阅读全文
posted @ 2010-01-12 10:18 零点零一 阅读(1479) 评论(0) 推荐(0)
.NET 4.0 数组比较
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1///<summary>2///NewFeaturein.NET4.03///Comparetwoarray4///usingIStructuralEquatable5///usingE... 阅读全文
posted @ 2010-01-04 18:01 零点零一 阅读(391) 评论(0) 推荐(0)
DIY播放器(使用MediaPlayer)
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1///themostimportantthingistoreferencetheMediaPlayerinCOMTab2///qixue3usingSystem;4usingSystem.Colle... 阅读全文
posted @ 2009-12-23 17:20 零点零一 阅读(473) 评论(0) 推荐(0)