私は次のコードを持っています:
public void DrawInput(string ChatCurrent){
int uCursorTop;
int uCursorLeft;
uCursorLeft = Console.CursorLeft;
uCursorTop = Console.CursorTop;
Console.SetCursorPosition(0, uCursorTop);
Console.Write("> "+ChatCurrent+" ");
Console.SetCursorPosition(ChatCurrent.Length, uCursorTop);
}
最終行を除いて、適切に動作します。最後の行はをスローしSystem.NullReferenceException: Object reference not set to an instance of an object
ます。変なこと?具体的には、アクセスChatCurrent.Length
が失敗の原因です。文字列の内容をエコーする直前の行は、問題なく機能します。
どうしたの?