问一道C# interview testing quesiton# JobHunting - 待字闺中
a*r
1 楼
class MyClass
{
private int numberOfCalls = 0;
private int numberOfLetters = 0;
static void ReverseString(String strIn)
{
char temp;
for (int i = 0; i < strIn.Length; i++)
{
temp = strIn[i];
strIn[i] = strIn[strIn.Length - i];
strIn[strIn.Length - i] = temp;
}
numberOfCalls++;
Console.WriteLine(String.Format("This function has been called {
0}", numberOfCalls));
}
}
望高人指点上面的程序有何flaws
{
private int numberOfCalls = 0;
private int numberOfLetters = 0;
static void ReverseString(String strIn)
{
char temp;
for (int i = 0; i < strIn.Length; i++)
{
temp = strIn[i];
strIn[i] = strIn[strIn.Length - i];
strIn[strIn.Length - i] = temp;
}
numberOfCalls++;
Console.WriteLine(String.Format("This function has been called {
0}", numberOfCalls));
}
}
望高人指点上面的程序有何flaws