지금은 for 루프가 있으며 값이있는 텍스트 상자를 하나만 설정하고 있습니다. 이 문제를 해결할 수있는 방법이 많이 있습니다. 여기 내 제안은 두 번째 텍스트 상자 textoutput2이라는 가정이다 : (. 그때, int를 받고, TryParse를 사용하지 않는 팀 Schmelter의 생각을 복용 문자열로 변환하는거야)
string Stack = "azersdj8qsdfqzer17";
string[] digits = Regex.Split(Stack, @"\D+");
textoutput.Text = "replace";
textoutput2.Text = "replace";
foreach (string value in digits)
{
if (textoutput.Text == "replace") {
textoutput.Text = value;
} else {
textoutput2.Text = value;
}
}
이 여전히 가지입니다 첫 번째 텍스트를 설정하고 발견 된 다른 모든 숫자에 대해 두 번째 값만 설정하기 때문에 좋지 않지만 텍스트 상자의 수에 관계없이 쉽게 확장 할 수 있습니다.3 개 상자 :
string Stack = "azersdj8qsdfqzer17";
string[] digits = Regex.Split(Stack, @"\D+");
textoutput.Text = "replace";
textoutput2.Text = "replace";
textoutput3.Text = "replace";
foreach (string value in digits)
{
if (textoutput.Text == "replace") {
textoutput.Text = value;
} else if (textoutput2.Text == "replace") {
textoutput2.Text = value;
} else {
textoutput3.Text = value;
}
}
는, 또는 동적으로 생성 된 텍스트 상자와 텍스트 상자의 배열과 당신이 그것을 할 수있는 다른 방법이 있습니다, 그러나 이것은 기본적인 시작이다.
항상 두 개의 숫자 만 표시됩니까? 현재 루프의 이전 값을 덮어 쓰는'textoutput.Text ='를 사용하고 있습니다. – keyboardP
예, 항상 두 개의 숫자가됩니다. 하지만 X 번호를 만드는 방법을 알면 –