D:\ Learning \ CS \ Resource \ Tutorial \ C#LangTutorialを出力したいのですが、動作し ません。コンパイラエラーエラーCS0165:割り当てられていないローカル変数の使用'StrPathHead コードを修正する方法または私の場合の他のより良い解決策についてアドバイスをください。ありがとうございました。
static void Main(string[] args)
{
string path = "D:\\Learning\\CS\\Resource\\Book\\C#InDepth";
int n = 0;
string[] words = path.Split('\\');
foreach (string word in words)
{
string StrPathHead;
string StrPath;
Console.WriteLine(word);
if (word == "Resource")
{
StrPath = StrPathHead + word + "\\Tutorial\\C#LangTutorial";
}
else
{
StrPathHead += words[n++] + "\\";
}
}
}