我目前正在尝试复制一种将真值表转换为 C# 中的布尔表达式的方法。我已经能够生成一个 3 变量 (a,b,c) 真值表并将其显示在多行文本框中。我为每个输入的输出创建了另外八个文本框供用户决定:要么true(1)
或false(0)
. 但是在生成表格之后,我如何才能显示所有具有true
值的输出?
public partial class Form1 : Form
{
public Form1() => InitializeComponent();
string newLine = Environment.NewLine;
bool a, b, c, d;
private void Form1_Load(object sender, EventArgs e)
{
textBox1.AppendText(newLine + "A" + "\t" + "B" + "\t" + "C" + newLine);
textBox1.AppendText("______________________________" + newLine);
a = true; b = true; c = true;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c +newLine);
textBox1.AppendText("______________________________" + newLine);
a = true; b = true; c = false;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = true; b = false; c = true;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = true; b = false; c = false;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = false; b = true; c = true;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = false; b = true; c = false;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = false; b = false; c = true;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
a = false; b = false; c = false;
textBox1.AppendText(newLine + a + "\t" + b + "\t" + c + newLine);
textBox1.AppendText("______________________________" + newLine);
}
private void button1_Click(object sender, EventArgs e)
{
//Grab true value outputs and display in string
}
}
上表是一个例子。我想以某种方式显示真实的输出值:
结果如下: FALSE TRUE TRUE TRUE FALSE TRUE TRUE TRUE FALSE TRUE TRUE False