2012年11月22日

C#序列化JSON

摘要: 首先先添加.NET引用System.Runtime.Serialization.dllSystem.ServiceModel.Web.dll然后CS文件添加USing 引用usingSystem.ServiceModel.Web;usingSystem.Runtime.Serialization.Json;usingSystem.IO;usingSystem.Text;把JSON序列化成对象///<summary>///反序列化JSON///</summary>///<typeparamname="T">返回类型</typepara 阅读全文

posted @ 2012-11-22 14:36 梦想飞的鱼 阅读(223) 评论(0) 推荐(0) 编辑

2012年11月21日

C#的序列化和反序列化

摘要: 对象:[Serializable]publicclassUser{publicstringID{get;set;}publicstringName{get;set;}}将对象实体序列化成字符串publicstaticstringXMLSerialize<T>(Tentity){StringBuilderbuffer=newStringBuilder();XmlSerializerserializer=newXmlSerializer(typeof(T));using(TextWriterwriter=newStringWriter(buffer)){serializer.Seria 阅读全文

posted @ 2012-11-21 12:41 梦想飞的鱼 阅读(187) 评论(0) 推荐(0) 编辑

2012年11月16日

后台调用前台js脚本的方法总结

摘要: 1、直接在前台调用 javascript 函数 很简单,在 head 元素之间加入 script 元素,将 type 元素设置为 " text/javascript " 如: 复制代码 代码如下:<head runat="server"> <script type="text/javascript" > function ShowName(str) { alert("您的名字为:("+str+")"); } </script> <title>usi 阅读全文

posted @ 2012-11-16 13:23 梦想飞的鱼 阅读(278) 评论(0) 推荐(0) 编辑

2012年9月24日

Linq to Sql 自定义实体类带关系映射

摘要: 表T_Person: 学生表 有一个外键关键班级表表T_Class:班级表[Table(Name="T_Class")]publicclassClass{privateint_classid;privatestring_classname;privateEntitySet<Person>_persons;[Column(IsPrimaryKey=true)]publicintClassTypeID{get{return_classid;}set{if(_classid!=value)_classid=value;}}[Column]publicstringCla 阅读全文

posted @ 2012-09-24 15:08 梦想飞的鱼 阅读(389) 评论(0) 推荐(0) 编辑

2012年8月23日

Linq To Sql数据库操作基类实现不同条件的增删改查

摘要: usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingCRM.Model;usingSystem.Configuration;usingSystem.Linq.Expressions;usingSystem.Data.SqlClient;usingSystem.Data.Linq;namespaceCRM.DAL{///<summary>///Linq数据访问层///</summary>publicclassLinqHelper{///<summary& 阅读全文

posted @ 2012-08-23 09:23 梦想飞的鱼 阅读(416) 评论(0) 推荐(0) 编辑

2012年8月5日

C#异步回调

摘要: 异步回调是指异步执行一个带回调函数的方法;代码如下classProgram{staticvoidMain(string[]args){Action<string>A1=newAction<string>(Show);A1.BeginInvoke("Hello",Callback,"回调参数");Console.Read();}//回调方法publicstaticvoidCallback(IAsyncResultar){objectstr=ar.AsyncStateasstring;Console.WriteLine(str);}/ 阅读全文

posted @ 2012-08-05 11:07 梦想飞的鱼 阅读(380) 评论(0) 推荐(0) 编辑

2012年7月27日

Silerlight 控制datagrid控件多选时不显示详细信息

摘要: 在datagrid SelectionChanged事件增加以下代码,如果当前选择的数量大于1,则把详细信息收缩,否则,当选定的时候在咱开。privatevoiddgList_SelectionChanged(objectsender,SelectionChangedEventArgse){if(this.dgList.SelectedItems.Count>1){dgList.RowDetailsVisibilityMode=DataGridRowDetailsVisibilityMode.Collapsed;}elsedgList.RowDetailsVisibilityMode=D 阅读全文

posted @ 2012-07-27 16:44 梦想飞的鱼 阅读(143) 评论(0) 推荐(0) 编辑

2012年7月7日

C#WinForm调用子窗体并接收数据

摘要: 我们在开发WinForm程序的时候经常会遇到这样一个问题,当用户在主窗体点击一个按钮,需要弹出一个子窗体让用户输入信息,然后在子窗体点击确定后把刚才输入的信息返回到主窗体的界面上。这个效果我暂时知道有2中方法可以实现,第一种是通过事件,第二种是通过using。下面演示第二种方法1:这是Form2的代码就简单的一个输入框和一个和两个buttonusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usi 阅读全文

posted @ 2012-07-07 11:41 梦想飞的鱼 阅读(1277) 评论(0) 推荐(0) 编辑

2012年7月6日

C#Form运行外部程序

摘要: 1:首先先添加命名空间,using System.Diagnostics;2:调用Process.Start()方法,括号里面写程序路径usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Diagnostics;namespaceWindowsFormsApplication1{public 阅读全文

posted @ 2012-07-06 09:10 梦想飞的鱼 阅读(200) 评论(0) 推荐(0) 编辑

2012年6月28日

C#基础-Func,Action[转]

摘要: Func,Action 的介绍及其用法Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如在反射中使用就可以弥补反射所损失的性能。Action<T>和Func<T,TResult>的功能是一样的,只是Action<T>没有返类型,Func<T,T,Result>:有参数,有返回类型Action,则既没有返回也没有参数,Func<T,TResult> 的表现形式分为以下几种:1。Func<T,TResult>2。Fun 阅读全文

posted @ 2012-06-28 16:15 梦想飞的鱼 阅读(267) 评论(0) 推荐(0) 编辑

导航