随笔分类 -  C#

摘要:public ActionResult test() { List<Model> list = new List<Model>() { new Model() { id = 1, name = "aa" }, new Model() { id = 2, name = "bb" } }; var cc = list.Select(deleg... 阅读全文
posted @ 2012-10-24 17:36 pantherbean 阅读(190) 评论(0) 推荐(0)
摘要:1.在类中创建一个返回值是List<T>的方法,注意:返回值必须是List<T>,不能是其它类型,如string,int,否则当报表新建数据集的时候,是找不到数据源的.2.新建报表Report1.rdlc3.新建数据集4.插入表5 在表填入数据集中的字段6 protected void Page_Load(object sender, EventArgs e) { LocalReport report = new LocalReport(); //新建报表对象 report.ReportPath = Server.MapPath("/r... 阅读全文
posted @ 2012-10-10 11:20 pantherbean 阅读(292) 评论(0) 推荐(0)
摘要:cc 阅读全文
posted @ 2012-09-14 11:31 pantherbean 阅读(496) 评论(0) 推荐(0)
摘要:#region 在url后加一个参数 public static string AddUrlParam(string key, string value) { var dd = System.Web.HttpContext.Current.Request.QueryString; Dictionary<string, string> dic = new Dictionary<string, string>(); foreach (string key2 in dd.AllKeys) ... 阅读全文
posted @ 2012-08-14 16:29 pantherbean 阅读(975) 评论(0) 推荐(0)
摘要:在iis中设置如上,然后在hosts文件中加:127.0.0.1 tt.cn然后就在可以用以下方式访问:1. 127.0.0.12. localhost3. 本机ip4. tt.cn如果设置ip地址,用其它方式可能不能访问. 阅读全文
posted @ 2012-08-11 22:01 pantherbean 阅读(241) 评论(0) 推荐(0)
摘要:1 //简单邮件传输协议类 2 System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); 3 client.Host = "smtp.163.com";//邮件服务器 4 client.Port = 25;//smtp主机上的端口号,默认是25. 5 client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//邮件发... 阅读全文
posted @ 2012-08-08 21:41 pantherbean 阅读(11781) 评论(0) 推荐(3)
摘要:说明一下,类中的HttpContext.Current.Response.ContentType表示要导出文件的类型,下面是对Response.ContentType类型的汇总在ASP.NET中使用Response.ContentType="类型名";来确定输出格式'ez'=>'application/andrew-inset','hqx'=>'application/mac-binhex40','cpt'=>'application/mac-compactpro 阅读全文
posted @ 2012-08-07 09:25 pantherbean 阅读(694) 评论(0) 推荐(0)
摘要:新建一个网站时:完整路径:G:\wwwroot\WebSite1 WebSite1文件夹下有文件:Default.aspx默认虚拟路径:/WebSite1所以访问的时候应该这样:http://localhost:14595/WebSite1/Default.aspx虚拟路径可以随便改:如改成 /,那么访问的时候就应该这样:http://localhost:14595/Default.aspx,如改成:/aa/bb/cc 访问:http://localhost:14595/aa/bb/cc/Default.aspx新建一个Asp.net Web应用程序时,默认虚拟路径是: /,不可以改成别的.. 阅读全文
posted @ 2012-03-31 15:38 pantherbean 阅读(434) 评论(0) 推荐(0)
摘要:static void Main(string[] args) { int intOut;//这里可以赋值,但赋的值在方法funout()中会被清空 funOut(out intOut);//这里out必须写 Console.Write(intOut);//输出1 int intRef = 1;//这里必须赋值,如果方法funref()中没有改变intRef,则输出原值 funRef(ref intRef);//这里ref必须写 Console.Wr... 阅读全文
posted @ 2012-03-31 15:12 pantherbean 阅读(253) 评论(0) 推荐(0)
摘要:IL_0000,标记代码开头,前面是变量的声明和初始化ldarg.0(load argument),装载第一个成员参数,在实例方法中指的是当前实例的引用call,一般用于调用静态方法,因为静态方法是在编译期指定的,而在此处call并非调用静态方法,而是构造函数.actor(),也是在编译期指定的callvirt,调用实例方法,函数调用是在运行时确定的,检查是否是虚函数,不是就直接调用,若是则向下检查是否有重写,.ret(return),执行完毕.ldstr(load string),将字符串压栈,从内存装载到堆栈上的操作指令通常以ld(load加载)开头,而每一条指令都对应了一条存储指令,通常 阅读全文
posted @ 2012-03-02 23:12 pantherbean 阅读(246) 评论(0) 推荐(0)
摘要:class Program { string name; int age; public string Name { get { return name; } set { this.name = value; } } static void Main(string[] args) { //无参构造函数来实例化类 object obj = Assembly.Load("ConsoleApp").Cr... 阅读全文
posted @ 2012-03-01 10:13 pantherbean 阅读(191) 评论(0) 推荐(0)
摘要:应用程序域: 所有的.Net 应用程序都运行在托管环境(managed environment)中,但操作系统只提供进程(Process)供程序运行,而进程只是提供了基本的内存管理,它不了解什么是托管代码。所以托管代码,也可以说是我们创建的.Net程序,是无法直接运行在操作系统进程中的。为了使托管代码能够运行在非托管的进程之上,就需要有一个中介者,这个中介者可以运行于非托管的进程之上,同时向托管代码提供运行的环境。这个中介者就是应用程序域(Application Domain,简写为App Domain)。所以我们的.Net程序,不管是Windows窗体、Web窗体、控制台应用程序,又或者是. 阅读全文
posted @ 2012-02-27 16:29 pantherbean 阅读(217) 评论(0) 推荐(0)
摘要:Stream:数据流是一个抽象基类,派生FileStream实例与MemoryStream实例,自己本身不能实例化,只能由派生类来初始化.FileStream:文件流,主要对文件的操作,向文件写入数据,从文件中读取数据.实例化时,有一个文件路径参数.MemoryStream:内存流,实例化时,参数是字节数组byte[],字符串转化为字节数组: 1、byte[] str=Encoding.UTF8.getBytes("字符串"); 2、byte[] str=Encoding.GetEncoding("gb2312").GetBytes("字符串& 阅读全文
posted @ 2012-02-25 16:01 pantherbean 阅读(1337) 评论(0) 推荐(0)
摘要:public class bird { public string type = "bird"; public virtual void write() { Program.print("type is bird"); } } public class chicken : bird { public string type = "chicken"; public override void write() { Program.pr... 阅读全文
posted @ 2012-02-22 16:08 pantherbean 阅读(411) 评论(0) 推荐(0)
摘要:两个排序接口:IComparable与IComparer,均有泛型支持public interface IComparable { int CompareTo(object obj); }public interface IComparer{ int Compare(object x,object y);}基类型都实现了IComparable.string a = "aa";string b = "bb";int return = a.CompareTo(b);return=-1;返回值:a>b,返回1;a=b,返回0;a<b,返回-1.in 阅读全文
posted @ 2012-02-18 16:27 pantherbean 阅读(377) 评论(0) 推荐(0)