2011-02-03 3 views
4

내가 콘솔로 할 수있는 여러 I/O 작업이 있습니다C# 고급 콘솔 I/O를

  • 인쇄 표준 출력을, 비 편집 가능한 텍스트 (Console.WriteLine())
  • 인쇄 아웃 텍스트 그 사용자는 내가 너무 password masking을 할 수 있다면 좋을 텐데 (?)
  • 은 사용자가 입력 할 수 있도록 허용 편집하고 (?)
    • 위의 두 가지 방법을 통해 텍스트를 출력 할 수 있습니다.

아무 해결책이 있습니까?

답변

2

어쩌면 저주를 시도해 볼 수도 있습니다. C# wrapper avaiable입니다. 그래도 직접 시도하지 않았습니다 ...

0

대답은 이미 제출하지만 아래의 코드는

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace ConsoleApplication1 
{ 
class Program 
{ 
    public static int i = 0; 
    public static string[] S = new string[] { "A", "B", "C", "D", "E", "F" }; 
    static void Main(string[] args) 
    { 

     Console.Write("Please Select : "+S[i]); 
     ConsoleKeyInfo K = Console.ReadKey(); 
     while (K.Key.ToString() != "Enter") 
     { 
      Console.Write(ShowOptions(K)); 
      K = Console.ReadKey(); 
     } 
     Console.WriteLine(""); 
     Console.WriteLine("Option Selected : " + S[i]); 

     Console.ReadKey(); 
     } 
    public static string ShowOptions(ConsoleKeyInfo Key) 
    { 

     if(Key.Key.ToString() == "UpArrow") 
     { 
      if (i != S.Length-1) 
       return "\b\b" + S[++i]; 
      else 
       return "\b\b" + S[i]; 
     } 
     else if (Key.Key.ToString() == "DownArrow") 
     { 
      if(i!=0) 
      return "\b\b" + S[--i]; 
      else 
       return "\b\b" + S[i]; 
     } 

     return ""; 
    } 
} 

} 
도움이 될 수 있습니다