Dzień dobry, posiadam tablicę obiektów. W okienku tekstowym chcę wyświetlić tekst + numer obiektu z tablicy + 1. Mam problem z numerem obiektu, jak to napisać. Prosiłbym o pomoc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Guy[] guys = new Guy [3];
Greyhound[] dogs = new Greyhound[4];
Random Randomizer = new Random();
public Form1()
{
InitializeComponent();
guys[0] = new Guy() { Name = "Janek", Cash = 50, MyRadioButton = this.janekRadioButton, MyLabel = this.janekBetLabel };
guys[1] = new Guy() { Name = "Bartek", Cash = 75, MyRadioButton = this.bartekRadioButton, MyLabel = this.bartekBetLabel };
guys[2] = new Guy() { Name = "Arek", Cash = 100, MyRadioButton = this.arekRadioButton, MyLabel = this.arekBetLabel };
dogs[0] = new Greyhound() { MyPictureBox = pictureBox2, StartingPosition = pictureBox2.Location.X, RaceTrackLenght = pictureBox1.Width, MyRandom = Randomizer };
dogs[1] = new Greyhound() { MyPictureBox = pictureBox3, StartingPosition = pictureBox3.Location.X, RaceTrackLenght = pictureBox1.Width, MyRandom = Randomizer };
dogs[2] = new Greyhound() { MyPictureBox = pictureBox4, StartingPosition = pictureBox4.Location.X, RaceTrackLenght = pictureBox1.Width, MyRandom = Randomizer };
dogs[3] = new Greyhound() { MyPictureBox = pictureBox5, StartingPosition = pictureBox5.Location.X, RaceTrackLenght = pictureBox1.Width, MyRandom = Randomizer };
}
private void button1_Click(object sender, EventArgs e) // tutaj chcialem zeby w labelach po prawej stronie w labelach wpisywane byly zaklady ale nie dziala
{
foreach (Guy guy in guys)
{
if (guy.MyRadioButton.Checked)
{
if (guy.PlaceBet ((int)numericUpDownBetSize.Value, (int)numericUpDownDogNumber.Value))
{
guy.MyLabel.Text = guy.MyBet.GetDescription();
}
}
}
}
private void janekRadioButton_CheckedChanged(object sender, EventArgs e)
{
label1.Text = "Janek";
}
private void bartekRadioButton_CheckedChanged(object sender, EventArgs e)
{
label1.Text = "Bartek";
}
private void arekRadioButton_CheckedChanged(object sender, EventArgs e)
{
label1.Text = "Arek";
}
private void button2_Click(object sender, EventArgs e)
{
foreach (Greyhound dog in dogs)
{
timer1.Start();
}
}
public void timer1_Tick(object sender, EventArgs e)
{
foreach (Greyhound dog in dogs)
{
if (dog.Run())
{
timer1.Stop();
if (dog.Run() == true)
{
MessageBox.Show("Zwycięzcom gratulujemy! wygrał chart numer " + ); **TUTAJ PROBLEM**
}
}
}
}
}
chciałem użyć dogs.indexOf(Dog) czy jakos tak ale wyskakuje mi blad
wyskakuje mi taki błąd
Error 2 'System.Array' does not contain a definition for 'indexOf' and no extension method 'indexOf' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
dodanie znacznika <code class="none">
- @furious programming