한 문자열 변수 안에있는 모든 알파벳을 어떻게 확인할 수 있습니까? 문장을 1과 0으로 번역 할 수있는 프로그램을 만들려고합니다. 아래 코드를 살펴보면, 지금 당장에 얼마나 많이했는지 알 수 있습니다. 나는 텍스트 파일에서 값을 읽고 한 문자 만 쓸 수 있습니다. 나는이 문장의 모든 문자를 확인 할 수 있도록 내 코드를 작성하는 방법을 알고 싶습니다.! [1]한 문자열 변수 안에있는 모든 알파벳을 어떻게 확인할 수 있습니까?
Dictionary<string, string> dictionary = new Dictionary<string, string>();
string[] lines = File.ReadAllLines("Values.txt");
for (int i = 0; i < 4; i++)
{
string value = lines[i].Substring(4);
string identifier = lines[i].Substring(0, 1);
dictionary.Add(identifier, value);
}
string sentence = Console.ReadLine();
if (sentence == "A")
{
Console.WriteLine(dictionary[sentence]);
}
else if (sentence == "B")
{
Console.WriteLine(dictionary[sentence]);
}
Console.ReadKey();
나는 친구에게서 도움을 얻었다. 그들은 여기서 도움을 주신 Thx입니다. – SaadRH