StringCollection 是专用于储存字符串的集合, 相当于字符串的动态数组.
主要成员:
/* 属性 */ Count; // /* 方法 */ Add(); //添加字符串 AddRange(); //添加字符串数组 Clear(); //清空 Contains(); //是否存在 CopyTo(); //复制到字符串数组 IndexOf(); //取索引, 无则 -1 Insert(); //插入 Remove(); //删除指定元素 RemoveAt(); //根据索引删除
简单测试:
protected void Button1_Click(object sender, EventArgs e) { StringCollection sc = new StringCollection(); sc.Add("AAA"); sc.Add("BBB"); sc.AddRange(new string[3] {"one", "two", "three"}); sc.Insert(1, "111"); sc.Insert(0, "000"); string str = ""; for (int i = 0; i < sc.Count; i++) { str += sc[i] + "; "; } TextBox1.Text = str; //000; AAA; 111; BBB; one; two; three; } protected void Button2_Click(object sender, EventArgs e) { StringCollection sc = new StringCollection(); string[] strArr = "aaa,bbb,ccc,ddd,eee,fff".Split(','); sc.AddRange(strArr); sc.RemoveAt(2); sc.Remove("ddd"); string str = ""; foreach (string s in sc) { str += s + "; "; } TextBox1.Text = str; //aaa; bbb; eee; fff; }
微软这次为MVC新建了三个DLL库,分别是System.Web.MVC.DLL(MVC的主要类,中间集成了大部分原来mvctoolkit的方法);System.Web.Abstractions.DLL(HttpContextBase,HTT…
1、新建网站(或者asp.netWeb应用程序)2、创建一个类。继承System.Web.UI.Page,重写InitializeCulture()方法。类名:BasePage3、InitializeCulture()这样实现:String…
1、SQL语句分类1.1、分类方法及类型1.2、数据定义语言1.3、数据操纵语言1.4、其它语句2、动态SQL理论2.1、动态SQL的用途2.2、动态SQL的语法2.3、绑定变量3、动态SQL实战3.1、封装执行DML的通用存储过程3.2、…
简介在C#中,Dictionary提供快速的基于兼职的元素查找。当你有很多元素的时候可以使用它。它包含在System.Collections.Generic名空间中。在使用前,你必须声明它的键类型和值类型。详细说明必须包含名空间System…
就像WebApi接口可以对入参进行验证,避免用户传入非法的或者不符合我们预期的参数一样,选项也可以对配置源的内容进行验证,避免配置中的值与选项类中的属性不对应或者不满足预期,毕竟大部分配置都是通过字符串的方式,验证是很有必要的。1.注解…
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Con…
普通的邮件,用System.Net.Mail类或System.Web.Mail类处理即可,但是ExchangeServer环境下,这两个类起不了作用-------至少目前我看到的情况如此.整个过程如下:1.先添加COM引用"Microsof…
第一步:定义一个类:SysHandlerErrorAttribute继承HandleErrorAttribute重写OnException方法usingDw.Util;usingSystem;usingSystem.Collections.…