日期:2014-05-17 浏览次数:20853 次
static void Main(string[] args)
{
string str = @"aaaa
bbbbb
cccccccccc
dd
dd
eeee";
string[] s = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
Console.WriteLine("行数:" + s.Length);
//if(s.Length==0)return;
List<string> mins = new List<string>();
mins.Add(s[0]);
List<string> maxs = new List<string>();
maxs.Add(s[0]);
for (int i = 1; i < s.Length; i++)
{
if (s[i].Length <= mins[0].Length)
{
if (s[i].Length < mins[0].Length)
mins.Clear();
mins.Add(s[i]);
}
if (s[i].Length >= maxs[0].Length)
{
if (s[i].Length > maxs[0].Length)
maxs.Clear();
maxs.Add(s[i]);
}
}
Console.WriteLine