나는 대학 1 학년이며 우리는 C#을하고 있습니다. 섭씨와 화씨 사이에서 변환 할 수있는 Winforms 앱을 만들어야합니다. 모든 코드가 (기본적으로) 아래에 있지만 결과 출력을 레이블로 가져와야합니다. lblOutput = Output.ToString();
레이블의 답을 보낼 수 있지만 "[입력] 섭씨는 화씨입니다."와 같은 메시지가 필요합니다. "ToString"다음에 괄호 사이에 넣으려고했지만 오류가 발생했습니다.문자열을 표시하는 코드
나는 이것을 제외하고는 다른 모든 코드가 있습니다. 나는 그것을 이해하기 위해 지난 며칠 동안 찾고 있었지만 대답을 찾을 수 없습니다. 어떤 도움이라도 대단히 감사합니다.
편집 :
설정 한 코드는 버튼 안에 표시됩니다. 나는 두 개의 라디오 버튼을 가지고 그 값이 텍스트 상자에 넣는다는 것을 멀리 -> Cels 또는 Cels -> Far라고합니다.
이것은 내 버튼으로 코딩 한 것입니다. 그것을 향상시킬 수있는 방법이 있으면 알려주십시오.
private void btnConvert_Click(object sender, EventArgs e)
{
decimal Input = Convert.ToDecimal(txtInput.Text); //grabs the input that the user entered
if (rbtnCelsius.Checked == true) //Test to see if the Celsius radio button is checked
{
decimal Output = ((Input - 32) * 5)/9; //If yes, it uses this formula to convert the input from Farenheit to Celsius
txtOutput.Text = Output.ToString(); //Outputs the message to the user, showing the Celsius end point
}
else //Says that the Celsius Radio Button is not checked, meaning that the Farenheit radio button is
{
decimal Output = (Input * 9)/5 + 32; //Moves onto this formula, converts Celsius to Farenheit
txtOutput.Text = Output.ToString(); //outputs the message to the user, showing the Farenheit end point
}
//txtOutput.Text = Output.ToString();
//Commented out because it gives an error saying that "Output does not exist in current context"
}
"WFA"가 "Windows Forms 응용 프로그램"이라고 가정합니다. –
예. 나는 내 질문에 Windows Form Application을 명시했고, 다시 입력하는 것을 느낄 수 없었습니다. –