c# - 我可以比较数组项吗?下面的代码和解释
问题描述
初学者程序员在这里,我正在尝试制作涂鸦。涂鸦是多人给出日期的地方,我的程序应该比较日期并显示所有三个人输入的日期中的哪一个是相同的。
namespace doodle_pittem
{
public partial class Form1 : Form
{
int teller1,teller2,teller3;
string[] Persoon1 = new string[5];
string[] Persoon2 = new string[5];
string[] Persoon3 = new string[5];
public Form1()
{
InitializeComponent();
}
private void TxtPersoon1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
{
Persoon1[teller1] = TxtPersoon1.Text;
TxtPersoon1.Text = "";
teller1++;
if (teller1==5)
{
TxtPersoon2.Focus();
TxtPersoon1.Enabled = false;
}
}
}
private void TxtPersoon2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
{
Persoon2[teller2] = TxtPersoon2.Text;
TxtPersoon2.Text = "";
teller2++;
if (teller2 == 5)
{
TxtPersoon3.Focus();
TxtPersoon2.Enabled = false;
}
}
}
private void TxtPersoon3_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
{
Persoon3[teller3] = TxtPersoon3.Text;
TxtPersoon3.Text = "";
teller3++;
if (teller3 == 5)
{
TxtPersoon3.Enabled = false;
BerekenDatum();
}
}
}
private void BerekenDatum()
{
string[] finaldatum = new string[15];
for (int i = 0; i < 1; i++)
{
foreach (string datum1 in Persoon1)
{
foreach (string datum2 in Persoon2)
{
foreach (string datum3 in Persoon3)
{
if (datum1 == datum2)
{
if (datum2 == datum3)
{
finaldatum[i] = datum1;
}
}
}
}
}
}
}
}
对于草率的代码或奇怪的变量名感到抱歉,但它们是荷兰语,因为这是我的主要语言。任何帮助或提示将不胜感激
解决方案
推荐阅读
- javascript - 之间的区别??和 ||
- swift - 当抛出 optional-nil 错误时,如何获取使用的默认错误字符串?
- javascript - 如何向游戏协调员发送多个请求?
- django - django.db.utils.IntegrityError: - 错误仍然存在
- python - Python 代码在 Win 10 与 Mac OS 上的表现更好
- tabulator - 你能把一个堆积条形图放在一个表格里吗?
- java - 我们如何知道线程已经完成了它的执行?
- javascript - 无法发送带有 PDF(*.pdf) 扩展名的文件
- sql - 在 Oracle 中获取子字符串
- c# - IMemoryCache - 单例或依赖注入