随笔分类 - C#
摘要:废话不多说,直接上代码 复制可 1 internal class NewExpressionVisitor : ExpressionVisitor 2 { 3 public ParameterExpression _NewParameter { get; private set; } 4 publi
阅读全文
摘要:首先需要引用程序集 Microsoft Script Control 1.0然后新建一个js文件,并写入相应的js方法//执行JS文件 private void btnjs_Click(object sender, EventArgs e) { //...
阅读全文
摘要:public static int Asc(string character) { if (character.Length == 1) { System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding...
阅读全文
摘要:#region 分钟数转换成倒计时,格式 _天_时_分 + string MinutesToCountdown(int Minutes) /// /// 将分钟数转换成倒计时 格式:_天_时_分 /// /// 分钟数 //...
阅读全文
摘要://定义类 public class MyClass { public int Property1 { get; set; } public string Property2 { get; set; } } MyClass tmp_Clas...
阅读全文
摘要:public static class ChineseToPinYin { private static readonly Dictionary CodeCollections = new Dictionary {{ -20319, "a" }, { -20317, "...
阅读全文
摘要:using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using Microsoft.International.Converters.Pin...
阅读全文
摘要:usingSystem; usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingMicrosoft.CSharp;usingSystem.CodeDom.Compiler;usingSystem.Reflecti...
阅读全文
摘要:usingSystem;usingSystem.Reflection;usingSystem.Globalization;usingMicrosoft.CSharp;usingSystem.CodeDom;usingSystem.CodeDom.Compiler;usingSystem.Text;n...
阅读全文
摘要:C#利用反射,遍历获得一个类的所有属性名,方法名,成员名 mogo41572013-05-1812:49Typet=typeof(System.Drawing.Color);//获取所有方法System.Reflection.MethodInfo[]methods=t.GetMethods();//...
阅读全文
摘要:格式说明符 说明 示例 输出 C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString("E") 2.500000E+005 F 固定点 25.ToString("F2") 25.00 G 常规 ...
阅读全文
摘要:定义一个枚举: private enum myType { a = 1, b = 2, c = 3, lao = 4 }//字符串转枚举 bool TryParse = Enum.IsDefined(typeof(myType), "a"); if (TryParse) { object m = Enum.Parse(typeof(myType), "c"); myType t = (myType)m; }//枚举转字符串myType.a....
阅读全文
摘要:public static DataSet ToDataSetByStream(string Stream) { DataSet ds = new DataSet(); StringReader str = new StringReader(Stream); XmlTextReader xm = new XmlTextReader(str); ds.ReadXml(xm); return ds; }
阅读全文
摘要:/// /// 将List集合 转换成 DataTable /// /// sellerSearchDealList是我自己定义的一个类 public static DataTable ListToTable(List entitys) { DataTable dtresult = new DataTable(); if (entitys == null || entitys.Count < 1) { throw new ...
阅读全文
摘要:http://www.cnblogs.com/jljxxf/archive/2012/08/19/2646937.html调用资源//定义一个类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.IO;using System.Reflection;namespace MyImg{ public static class ImageObject { /// /// 得到要绘置...
阅读全文
摘要:/// /// 将List集合 转换成 DataTable /// /// sellerSearchDealList是我自己定义的一个类 public static DataTable ListToTable(List entitys) { DataTable dtresult = new DataTable(); if (entitys == null || entitys.Count < 1) { throw n...
阅读全文
摘要:StringReader str = new StringReader(字节流); XmlTextReader xm = new XmlTextReader(str); DataSet ds = new DataSet(); ds.ReadXml(xm);
阅读全文
摘要:var stringlist = new List();//string List var objlist = new List(); //object List objlist.Add("abc"); objlist.Add(321); objlist.Add("啊不才"); objlist.Add('x'); //转换为List stringlist=objlist.ConvertAll(c => { return...
阅读全文
摘要:去掉该字符串中最后一个分隔符strComma是分隔符 if (str.Substring(str.Length - strComma.Length, strComma.Length) == strComma) { return str.Substring(0, str.Length - strComma.Length); }如果能保证该字符串的结尾一定是这个分隔符,那么也可以这样写 int index = str.LastIndexOf(strComma); return str.Substring...
阅读全文
摘要:/// /// 返回按AddDays拆分的时间段(包含多个逗号隔开) /// public static string StrTimes(DateTime starttime, DateTime endtime, int AddDays) { DateTime nowtime = starttime; string strtimes = starttime.ToString("yyyy-MM-dd HH:mm:ss") + ","; do { ...
阅读全文