摘要:
#region 根据URL获取结果集 /// /// 根据URL获取结果集 默认为GET,如果数据量大了可以传入POST /// /// URL地址 /// 默认为GET,删除时用DELETE /// String类型的,Json格式的结果集 public static string GetUrlResult(string url, string type = "GET") { string result = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); requ 阅读全文
摘要:
#region List 转 Json /// /// List 转 Json /// /// 实体对象 /// List对象 /// public static string ObjectToJson(T obj) { try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType()); using (MemoryStream ms = new MemoryStream()) { serializer.WriteObject(ms, obj); return Encod... 阅读全文
摘要:
public enum枚举名称 { /// ///注释描述1 /// [Description("注释描述1")]//通过Description可以通过C#方法读取到描述信息 Yes = 1, /// ///注释描述2 /// [Description("注释描述2")] No = 0 } 阅读全文
摘要:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Threading;namespace NetWorkCreeper{ public partial class Form2 : Form { public Form2() { InitializeComponent(); 阅读全文
摘要:
在C#中用多线程并不难实现。它有一个命名空间:System.Threading,提供了多线程的支持。 要开启一个新线程,须要以下的初始化:ThreadStart startDownload = new ThreadStart( DownLoad ); //线程起始设置:即每个线程都执行DownLoad(),注意:DownLoad()必须为不带有参数的方法Thread downloadThread = new Thread( startDownload ); //实例化要开启的新类downloadThread.Start();//开启线程 由于线程起始时启动的方法不能带有参数,这就为多线程共享. 阅读全文