您的位置:首页 > 理论基础 > 计算机网络

C# 的泛型以及网络下载Xml文件和读取Xml文件

2008-11-02 14:53 519 查看
一 、泛型

1) 通过泛型可以定义类型安全的数据类型,他的最显著的应用就是创建集合类,可以约束集合类内部的元素类型

二 、定义泛型
1)List 泛型 : List<Student> students = new List<Student>(); 集合泛型
2)Dictionary泛型 : Dictionary<string ,Student> students = new Dictionary<string , Student>(); 键值集合

三 、里氏替换原则
1) is 和 as 操作符的使用
is :判断 对象的类型是否相同
as :将对象的类型进行强制转换

四 、 网络下载 和 读取 XML 文件
1) using System.Net;
WebClient myClien = new WebClient();
myClient.DownLoadFile("下载地址", "文件保存名");
2) using System.Xml;
XmlDocument myXml = new XmlDocument();
myXml.Load("文件保存名");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: