asp.net泛型实例
来源:互联网 发布:王羲之兰亭序字帖知乎 编辑:程序博客网 时间:2024/05/22 01:53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Web_Test
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(GenericMethod.Output<int>(23) + "<br />");
Response.Write(GenericMethod.Output<string>("abc") + "<br />");
Response.Write("<br /><br />------------------------------------------------------------------------<br /><br />");
GenericChild gc = new GenericChild();
Response.Write(gc.Output<string, IComparable>("aaa", "xxx") + "<br />");
Response.Write(gc.Output2<System.Data.DataTable>(new System.Data.DataTable())+"<br />");
}
}
public class GenericMethod
{
public static string Output<T>(T t)
{
return "类型" + t.GetType().ToString() + ";值:" + t.ToString();
}
}
public abstract class GenericPrent
{
public abstract X Output<X, Y>(X x, Y y) where X : Y;
public abstract string Output2<X>(X x) where X : System.ComponentModel.IListSource;
}
public class GenericChild : GenericPrent
{
public override T Output<T, Z>(T t, Z z)
{
return t;
}
public override string Output2<T>(T t)
{
return t.GetType().ToString();
}
}
}
- asp.net泛型实例
- ASP.NET数据库连接实例
- 【asp.NET】分页实例
- ASP.NET数据库连接实例
- asp.Net Cookie实例
- asp.net mvc 实例
- asp.net Socket 实例
- asp.net Socket 实例
- asp.net Socket 实例
- Asp.net post 实例
- Asp.net MVC 实例
- ASP.net随机数应用实例
- ASP.net随机数应用实例
- ASP.net随机数应用实例
- asp.net,access数据库连接实例
- ASP.net AJAX代码实例。
- ASP.net随机数应用实例
- ASP.NET操作Excel实例
- struts2文件上传
- Solaris内存监控 & solaris查看内存使用情况
- 一个实用的在线解压缩php程序
- C#泛型
- Hibernate之Configuration,SessionFactory,Session
- asp.net泛型实例
- List IList区别
- 判断jtable是否被编辑过
- CG_Assignment_光线跟踪之光线散射
- shell变量2
- shell变量3
- 《微型计算机原理及应用》上第四章的汇编题目
- 电脑端口的含义详解
- 事务的回滚五种方法