编程新手,有个问题解决不了想请大家帮忙解决一下谢谢
using System;using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace 实验8
{
class Program
{
static void getCharCount(string b)
{
SortedList s1 = new SortedList();
IEnumerator OperandEnum = b.GetEnumerator();
int CharCount = 0;
//int m = 0, n;
while (OperandEnum.MoveNext())
{
int m, n;
CharCount++;
{
if (s1.Contains(OperandEnum.Current))
{
m = s1.IndexOfKey(OperandEnum.Current);
n = (int)s1.GetByIndex(m);
s1.SetByIndex(m, n + 1);
}
else
{
s1.Add(OperandEnum.Current, 1);
m = s1.IndexOfKey(OperandEnum.Current);
}
}
Console.WriteLine("{0} {1}", s1.GetKey(m), s1.GetByIndex(m));
}
//Console.WriteLine("{0} {1}", s1.GetKey(m), s1.GetByIndex(m));
Console.WriteLine(CharCount);
}
static void Main(string[] args)
{
string url = @"http//:127.0.0.1:8080/my-apps/chapter1/admin/adduser.jsp";
getCharCount(url);
}
}
}
上面是我写的一段代码想得到这样的输出结果在附件中有
实验八 字符串的操作.rar
(1016.69 KB)
,但我输出的结果却不是这样,而是每个字符都输出,请大家帮我解决一下。