请帮我看下这个C#问题
using System;using System.Collections.Generic;
using System.Text;
namespace chapter3_4
{
class Program
{
static void Main(string[] args)
{
string name;
string pascalName;
Console.WriteLine("请输入一个字符串,各单词以空格分隔:");
name = Console.ReadLine();
pascalName = ConvertToPascal(name);
Console.WriteLine("按Pascal规则转换后的名称是:"+pascalName);
Console.ReadLine();
}
private static string ConvertToPascal(string name)
{
string pascalName;
string tempWord;
string[] words;
words = name.Split(' ');
for (int i = 0; i<=words.Length; i++)
{
tempWord = words[i].Substring(0, 1).ToUpper();
pascalName = pascalName + tempWord;
tempWord = words[i].Substring(1).ToLower();
pascalName = pascalName + tempWord;
}
return pascalName;
}
}
}
为什么会报pascalName没有赋值,我这个是Pascal字符串转换法,请问改怎么修改?谢谢拉