日期:2014-05-17 浏览次数:20855 次
/// <summary>
/// 实现IComparable接口,用kcNum做比较
/// </summary>
/// <param name="obj">比较对象</param>
/// <returns>比较结果</returns>
public class KeChen : IComparable
{
public string kcName { get; set; }
public int kcNum { get; set; }
public int CompareTo(object obj)
{
if (obj is KeChen)
{
return kcNum.CompareTo(((KeChen)obj).kcNum);
}
return 1;
}
}
//查找子串的个数
private int findstring(string str1, string str2)
{
int i, j;
int str1len = str1.Length, str2len = str2.Length;
int count = 0;
for (i = 0; i < str1len - str2len + 1; i++)
{
for (j = 0; j < str2len; j++)
{
if (str2[j] != str1[i + j]) break;
}
if (j == str2len) count++;
}
return count;
}
private void button1_Click(object sender, EventArgs e)
{