Random
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
@@ -16,14 +17,49 @@ namespace WpfApp1
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
int[] ZufallsZahlen = new int[6];
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
ErzeugeZufallszahlen();
|
||||
InLabels();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ErzeugeZufallszahlen()
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
int index = 0;
|
||||
|
||||
while (index < 6)
|
||||
{
|
||||
int zahl = random.Next(1, 50);
|
||||
|
||||
if (ZufallsZahlen.Contains(zahl))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
ZufallsZahlen[index] = zahl;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InLabels()
|
||||
{
|
||||
Label0.Content = ZufallsZahlen[0].ToString();
|
||||
Label1.Content = ZufallsZahlen[1].ToString();
|
||||
Label2.Content = ZufallsZahlen[2].ToString();
|
||||
Label3.Content = ZufallsZahlen[3].ToString();
|
||||
Label4.Content = ZufallsZahlen[4].ToString();
|
||||
Label5.Content = ZufallsZahlen[5].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user