Click here to Skip to main content
15,890,609 members
Home / Discussions / C#
   

C#

 
AnswerRe: TcpListener don't send FIN after client send FIN Pin
Gerry Schmitz1-Apr-16 7:02
mveGerry Schmitz1-Apr-16 7:02 
GeneralRe: TcpListener don't send FIN after client send FIN Pin
Aurélien381-Apr-16 10:38
Aurélien381-Apr-16 10:38 
QuestionMulti threading with datatable in C# Pin
Jaimesh.24111-Apr-16 3:03
Jaimesh.24111-Apr-16 3:03 
GeneralRepost Pin
Sascha Lefèvre1-Apr-16 3:39
professionalSascha Lefèvre1-Apr-16 3:39 
QuestionFont error when using C# code behind to export from crystal report to pdf Pin
botngot8331-Mar-16 21:55
botngot8331-Mar-16 21:55 
AnswerRe: Font error when using C# code behind to export from crystal report to pdf Pin
Eddy Vluggen1-Apr-16 1:36
professionalEddy Vluggen1-Apr-16 1:36 
GeneralRe: Font error when using C# code behind to export from crystal report to pdf Pin
botngot833-Apr-16 22:05
botngot833-Apr-16 22:05 
QuestionIssue around converting Expression<Func<T, bool>> to Expression<Func<U, bool>> Pin
RichardGrimmer31-Mar-16 3:36
RichardGrimmer31-Mar-16 3:36 
AnswerRe: Issue around converting Expression<Func<T, bool>> to Expression<Func<U, bool>> Pin
Richard Deeming31-Mar-16 4:59
mveRichard Deeming31-Mar-16 4:59 
GeneralRe: Issue around converting Expression<Func<T, bool>> to Expression<Func<U, bool>> Pin
Sascha Lefèvre31-Mar-16 5:21
professionalSascha Lefèvre31-Mar-16 5:21 
GeneralRe: Issue around converting Expression<Func<T, bool>> to Expression<Func<U, bool>> Pin
Richard Deeming31-Mar-16 5:49
mveRichard Deeming31-Mar-16 5:49 
GeneralRe: Issue around converting Expression<Func<T, bool>> to Expression<Func<U, bool>> Pin
Sascha Lefèvre31-Mar-16 6:41
professionalSascha Lefèvre31-Mar-16 6:41 
QuestionUsing Deployment Item with Directory.GetFiles Pin
RamboSp31-Mar-16 2:17
RamboSp31-Mar-16 2:17 
AnswerRe: Using Deployment Item with Directory.GetFiles Pin
Eddy Vluggen1-Apr-16 1:33
professionalEddy Vluggen1-Apr-16 1:33 
Questioncurrent state of old issue of Enum boxing when used as Keys in a Dictionary ? Pin
BillWoodruff31-Mar-16 2:15
professionalBillWoodruff31-Mar-16 2:15 
AnswerRe: current state of old issue of Enum boxing when used as Keys in a Dictionary ? Pin
Richard Deeming31-Mar-16 2:52
mveRichard Deeming31-Mar-16 2:52 
QuestionMessage Removed Pin
31-Mar-16 0:25
PomegranateTiger31-Mar-16 0:25 
QuestionSync SQLite with Oracle or Postgre Pin
Potestas30-Mar-16 21:42
Potestas30-Mar-16 21:42 
AnswerRe: Sync SQLite with Oracle or Postgre Pin
Nathan Minier31-Mar-16 1:26
professionalNathan Minier31-Mar-16 1:26 
QuestionC# Tic Tac Toe "Simulator" Pin
Member 1242680830-Mar-16 11:24
Member 1242680830-Mar-16 11:24 
I'm very sorry if I didn't post my code correctly. I am having trouble with this. The code is working to the directions specifications, but, I am not sure about one thing. How do avoid getting....lets say....6 "O's" and 3 "X's" when I run the program. That is not simulation. Thanks.

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tic_Tac_Toe
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            const int ROWS = 3;
            const int COLS = 3;
            int[,] game = new int[ROWS, COLS];

            Random rand = new Random();

            for (int row = 0; row < ROWS; row++)
            {
                for (int col = 0; col < COLS; col++)
                {
                    game[row, col] = rand.Next(2);
                }
                if (game[0, 0] == 0)
                {
                    label2.Text = "O";
                }
                else
                {
                    label2.Text = "X";
                }
                if (game[0, 1] == 0)
                {
                    label3.Text = "O";
                }
                else
                {
                    label3.Text = "X";
                }
                if (game[0, 2] == 0)
                {
                    label4.Text = "O";
                }
                else
                {
                    label4.Text = "X";
                }
                if (game[1, 0] == 0)
                {
                    label5.Text = "O";
                }
                else
                {
                    label5.Text = "X";
                }
                if (game[1, 1] == 0)
                {
                    label6.Text = "O";
                }
                else
                {
                    label6.Text = "X";
                }
                if (game[1, 2] == 0)
                {
                    label7.Text = "O";
                }
                else
                {
                    label7.Text = "X";
                }
                if (game[2, 0] == 0)
                {
                    label8.Text = "O";
                }
                else
                {
                    label8.Text = "X";
                }
                if (game[2, 1] == 0)
                {
                    label9.Text = "O";
                }
                else
                {
                    label9.Text = "X";
                }
                if (game[2, 2] == 0)
                {
                    label10.Text = "O";
                }
                else
                {
                    label10.Text = "X";
                }

                if (game[0, 0] == 0 && game[0, 1] == 0 && game[0, 2] == 0)
                {
                    label11.Text = "O Wins";
                }
                 else if (game[0, 0] == 1 && game[0, 1] == 1 && game[0, 2] == 1)
                    {
                        label11.Text = "X Wins";
                    }
                else if (game[1, 0] == 0 && game[1, 1] == 0 && game[1, 2] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[1, 0] == 1 && game[1, 1] == 1 && game[1, 2] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[2, 0] == 0 && game[2, 1] == 0 && game[2, 2] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[2, 0] == 1 && game[2, 1] == 1 && game[2, 2] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[0, 0] == 0 && game[1, 0] == 0 && game[2, 0] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[0, 0] == 1 && game[1, 0] == 1 && game[2, 0] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[0, 1] == 0 && game[1, 1] == 0 && game[2, 1] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[0, 1] == 1 && game[1, 1] == 1 && game[2, 1] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[0, 2] == 0 && game[1, 2] == 0 && game[2, 2] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[0, 2] == 1 && game[1, 2] == 1 && game[2, 2] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[0, 0] == 0 && game[1, 1] == 0 && game[2, 2] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[0, 0] == 1 && game[1, 1] == 1 && game[2, 2] == 1)
                {
                    label11.Text = "X Wins";
                }
                else if (game[0, 2] == 0 && game[1, 1] == 0 && game[2, 0] == 0)
                {
                    label11.Text = "O Wins";
                }
                else if (game[0, 2] == 1 && game[1, 1] == 1 && game[2, 0] == 1)
                {
                    label11.Text = "X Wins";
                }
                else
                {
                    label11.Text = "DRAW";
                }


                


                }

            }
        }
    }

AnswerRe: C# Tic Tac Toe "Simulator" Pin
Sascha Lefèvre30-Mar-16 17:15
professionalSascha Lefèvre30-Mar-16 17:15 
AnswerRe: C# Tic Tac Toe "Simulator" Pin
Rob Philpott30-Mar-16 23:41
Rob Philpott30-Mar-16 23:41 
AnswerRe: C# Tic Tac Toe "Simulator" Pin
Patrice T31-Mar-16 0:55
mvePatrice T31-Mar-16 0:55 
RantREPOST Pin
Richard Deeming31-Mar-16 1:42
mveRichard Deeming31-Mar-16 1:42 
QuestionDynamically close DB2 CLP window using C# Pin
Tej_dev30-Mar-16 6:44
Tej_dev30-Mar-16 6:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.