从list中取出年份小于2010月份小于10的字符串以及它的位置:
private static void GetValue()
{
List<string> list = new List<string>();
list.Add("2010-8-frist");
list.Add("2008-12-second");
list.Add("2012-9-third");
for (int i = 0; i < 3; i++)
{
if (Convert.ToInt16(list[i].Substring(0, list[i].IndexOf('-'))) < 2010)
{
Console.WriteLine("{0},{1}", i, list[i]);
}
else
if ((Convert.ToInt16(list[i].Substring(0, list[i].IndexOf('-'))) == 2010))
{
if (Convert.ToInt16(list[i].Substring(list[i].IndexOf('-') + 1, list[i].LastIndexOf('-') - list[i].IndexOf('-') - 1)) < 10)
{
Console.WriteLine("{0},{1}", i, list[i]);
}
}
}
}