【发布时间】:2017-04-11 05:56:57
【问题描述】:
这里的新手程序员很抱歉,如果我错过了一些非常简单的东西,这是我的代码:
namespace Programming_Assignment_2
{
public partial class Form1 : Form
{
string combination;
const int MinLength = 6;
bool CombinationCheck(string combination)
{
if (combination.Length > 5)
return true;
else
return false;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btn_SetComb_Click(object sender, EventArgs e)
{
combination = My_Dialogs.InputBox("Please enter a password longer than 5 characters: ");
if (combination.Length < MinLength)
My_Dialogs.InputBox("Error! Please make sure password is longer than 5 characters: ");
else
{
MessageBox.Show("Thank you, password saved.");
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void text_SafeStatus_TextChanged(object sender, EventArgs e)
{
bool CombinationCheck;
if (
text_SafeStatus.Text("Combination Set"));
else (
text_SafeStatus.Text("Combination Not Set"));
}
}
}
所以底部的两个 .Text 会返回 Title 中的错误加上我在这里和那里得到一些小错误,例如
只有赋值、调用、递增、递减、等待和新对象表达式可以用作语句
else 后面的括号..
再次对可能是菜鸟的问题感到抱歉,但我似乎找不到特别帮助我的答案
编辑 1:
所以文本错误已为我修复,谢谢,但我还有另一个问题是试图从布尔值中获取真/假值并使用它来确定文本框显示的内容..
if bool CombinationCheck;
if CombinationCheck true;
text_SafeStatus.Text = "Combination Set";
else
text_SafeStatus.Text = "Combination Not Set";
这就是我目前拥有的,我不知道如何使这项工作。
【问题讨论】:
-
if (combinationCheck) {text_SafeStatus.Text = "组合集" } else {...}
-
@JeroenHeier 怎么样
CombinationCheck? text_SafeStatus.Text = "Combination Set" : text_SafeStatus.Text = "Combination Not Set"; -
@CameronFairbun,您应该接受解决您的 original 问题的答案,并为 new 问题发布 new 问题
标签: c#