I've been teaching myself how to program for a little bit now, and was hoping to get some critique on my most recent project, creating a Tic Tac Toe program! I'm hoping for people to point out some of the flaws within my code, and some areas in which I should try to improve on going forward.class Program{    static string[] pos = new string[10] { 0, 1, 2,3,4,5,6,7,8,9 }; // Array that contains board positions, 0 isnt used --------------------------------    static void DrawBoard() // Draw board method ==========================================    {        Console.WriteLine(   {0}  |  {1}  |  {2}   , pos[1], pos[2], pos[3]);        Console.WriteLine(-------------------);        Console.WriteLine(   {0}  |  {1}  |  {2}   , pos[4], pos[5], pos[6]);        Console.WriteLine(-------------------);        Console.WriteLine(   {0}  |  {1}  |  {2}   , pos[7], pos[8], pos[9]);    }    static void Main(string[] args) // Main ==============================================    {        string player1 = , player2 = ;        int choice = 0, turn = 1, score1 = 0, score2 = 0;        bool winFlag = false, playing = true, correctInput = false;        Console.WriteLine(Hello! This is Tic Tac Toe. If you don't know the rules then stop being an idiot.);        Console.WriteLine(What is the name of player 1?);        player1 = Console.ReadLine();        Console.WriteLine(Very good. What is the name of player 2?);        player2 = Console.ReadLine();        Console.WriteLine(Okay good. {0} is O and {1} is X. , player1, player2);        Console.WriteLine({0} goes first. , player1);        Console.ReadLine();        Console.Clear();        while (playing == true)        {            while (winFlag == false) // Game loop ------------------------------------------------------            {                DrawBoard();                Console.WriteLine();                Console.WriteLine(Score: {0} - {1}     {2} - {3}, player1, score1, player2, score2);                if (turn == 1)                {                    Console.WriteLine({0}'s (O) turn, player1);                }                if (turn == 2)                {                    Console.WriteLine({0}'s (X) turn, player2);                }                while (correctInput == false)                {                    Console.WriteLine(Which position would you like to take?);                    choice = int.Parse(Console.ReadLine());                    if (choice > 0 && choice < 10)                    {                        correctInput = true;                    }                    else                    {                        continue;                    }                }                correctInput = false; // Reset -------                if (turn == 1)                {                    if (pos[choice] == X) // Checks to see if spot is taken already --------------------                    {                        Console.WriteLine(You can't steal positions asshole! );                        Console.Write(Try again.);                        Console.ReadLine();                        Console.Clear();                        continue;                    }                    else                    {                        pos[choice] = O;                    }                }                if (turn == 2)                {                    if (pos[choice] == O) // Checks to see if spot is taken already -------------------                    {                        Console.WriteLine(You can't steal positions asshole! );                        Console.Write(Try again.);                        Console.ReadLine();                        Console.Clear();                        continue;                    }                    else                    {                        pos[choice] = X;                    }                }                winFlag = CheckWin();                if (winFlag == false)                {                    if (turn == 1)                    {                        turn = 2;                    }                    else if (turn == 2)                    {                        turn = 1;                    }                    Console.Clear();                }            }            Console.Clear();            DrawBoard();            for (int i = 1; i < 10; i++) // Resets board ------------------------            {                pos[i] = i.ToString();            }            if (winFlag == false) // No one won ---------------------------            {                Console.WriteLine(It's a draw!);                Console.WriteLine(Score: {0} - {1}     {2} - {3}, player1, score1, player2, score2);                Console.WriteLine();                Console.WriteLine(What would you like to do now?);                Console.WriteLine(1. Play again);                Console.WriteLine(2. Leave);                Console.WriteLine();                while (correctInput == false)                {                    Console.WriteLine(Enter your option: );                    choice = int.Parse(Console.ReadLine());                    if (choice > 0 && choice < 3)                    {                        correctInput = true;                    }                }                correctInput = false; // Reset -------------                switch (choice)                {                    case 1:                        break;                    case 2:                        Console.Clear();                        Console.WriteLine(Thanks for playing!);                        Console.ReadLine();                        playing = false;                        break;                }            }            if (winFlag == true) // Someone won -----------------------------            {                if(turn == 1)                {                    score1++;                    Console.WriteLine({0} wins! , player1);                    Console.WriteLine(What would you like to do now?);                    Console.WriteLine(1. Play again);                    Console.WriteLine(2. Leave);                    while (correctInput == false)                    {                        Console.WriteLine(Enter your option: );                        choice = int.Parse(Console.ReadLine());                        if (choice > 0 && choice < 3)                        {                            correctInput = true;                        }                    }                    correctInput = false; // Reset --------------                    switch (choice)                    {                        case 1:                            Console.Clear();                            winFlag = false;                            break;                        case 2:                            Console.Clear();                            Console.WriteLine(Thanks for playing!);                            Console.ReadLine();                            playing = false;                            break;                    }                }                if (turn == 2)                {                    score2++;                    Console.WriteLine({0} wins! , player2);                    Console.WriteLine(What would you like to do now?);                    Console.WriteLine(1. Play again);                    Console.WriteLine(2. Leave);                    while (correctInput == false)                    {                        Console.WriteLine(Enter your option: );                        choice = int.Parse(Console.ReadLine());                        if (choice > 0 && choice < 3)                        {                            correctInput = true;                        }                    }                    correctInput = false; // Reset -----------------                    switch (choice)                    {                        case 1:                            Console.Clear();                            winFlag = false;                            break;                        case 2:                            Console.Clear();                            Console.WriteLine(Thanks for playing!);                            Console.ReadLine();                            playing = false;                            break;                    }                }            }        }    }    static bool CheckWin() // Win checker method ================================================    {        if (pos[1] == O && pos[2] == O && pos[3] == O) // Horizontal ----------------------------------------        {            return true;        }        else if (pos[4] == O && pos[5] == O && pos[6] == O)        {            return true;        }        else if(pos[7] == O && pos[8] == O && pos[9] == O)        {            return true;        }        else if(pos[1] == O && pos[5] == O && pos[9] == O) // Diagonal -----------------------------------------        {            return true;        }        else if(pos[7] == O && pos[5] == O && pos[3] == O)        {            return true;        }        else if(pos[1] == O && pos[4] == O && pos[7] == O)// Coloumns ------------------------------------------        {            return true;        }        else if(pos[2] == O && pos[5] == O && pos[8] == O)        {            return true;        }        else if(pos[3] == O && pos[6] == O && pos[9] == O)        {            return true;        }        if (pos[1] == X && pos[2] == X && pos[3] == X) // Horizontal ----------------------------------------        {            return true;        }        else if (pos[4] == X && pos[5] == X && pos[6] == X)        {            return true;        }        else if (pos[7] == X && pos[8] == X && pos[9] == X)        {            return true;        }        else if (pos[1] == X && pos[5] == X && pos[9] == X) // Diagonal -----------------------------------------        {            return true;        }        else if (pos[7] == X && pos[5] == X && pos[3] == X)        {            return true;        }        else if (pos[1] == X && pos[4] == X && pos[7] == X) // Coloumns ------------------------------------------        {            return true;        }        else if (pos[2] == X && pos[5] == X && pos[8] == X)        {            return true;        }        else if (pos[3] == X && pos[6] == X && pos[9] == X)        {            return true;        }        else // No winner ----------------------------------------------        {            return false;        }    }}
Simple C# console Tic Tac Toe program
c#;beginner;tic tac toe
OK .. I took a look at your code. Let's do this one step at a time... I'm using VisualStudio with Resharper Installed. This causes a big chunk of your code to grey out. The if clause if (winFlag == false) // No one won ---------------------------{  ...}This is because the winFlag can't be false. This is due to the above look only exiting when the winFlag is true.So... there is a problem in there. We will get to that. Let's do some cleanup. CheckWin is a good place to start. Lots of verbosity. The need to add comments shows the method doesn't speak by itself.     if(Pos[1] == O && Pos[5] == O && Pos[9] == O) // Diagonal -----------------------------------------    {        return true;    }This pattern repeats... what is it doing? Checking for a line. Lets add a method for that.     private static bool IsLine(int index0, int index1, int index2, string piece)    {        return Pos[index0] == piece && Pos[index1] == piece && Pos[index2] == piece;    }Applying that function we get ...static bool CheckWin() // Win checker method ================================================    {        if (IsLine(1, 2, 3, O)) // Horizontal ----------------------------------------        {            return true;        }        if (IsLine(4, 5, 6, O))        {            return true;        }        if (IsLine(7, 8, 9, O))        {            return true;        }        if(IsLine(1, 5, 9, O)) // Diagonal -----------------------------------------        {            return true;        }        if(IsLine(7, 5, 3, O))        {            return true;        }        if(IsLine(1, 4, 7, O))// Coloumns ------------------------------------------        {            return true;        }        if(IsLine(2, 5, 8, O))        {            return true;        }        if(IsLine(3, 6, 9, O))        {            return true;        }        if(IsLine(1, 2, 3, X)) // Horizontal ----------------------------------------        {            return true;        }        if(IsLine(4, 5, 6, X))        {            return true;        }        if(IsLine(7, 8, 9, X))        {            return true;        }        if(IsLine(1, 5, 9, X)) // Diagonal -----------------------------------------        {            return true;        }        if(IsLine(7, 5, 3, X))        {            return true;        }        if(IsLine(1, 4, 7, X)) // Coloumns ------------------------------------------        {            return true;        }        if(IsLine(2, 5, 8, X))        {            return true;        }        if(IsLine(3, 6, 9, X))        {            return true;        }        return false;    }Okay, nice, but there is another chunk of duplication. All the tests get done twice, once with 'O' and once with 'X'. Lets deal with that.... now we can do this in a couple of ways. Loop over possible pieces, or just change the IsLine to check all the pieces in the line match. Lets try the second.     private static bool IsAnyLine(int index0, int index1, int index2)    {        return IsLine(index0, index1, index2, Pos[index0]);    }And we get:     static bool CheckWin() // Win checker method ================================================    {        if(IsAnyLine(1, 2, 3)) // Horizontal ----------------------------------------        {            return true;        }        if(IsAnyLine(4, 5, 6))        {            return true;        }        if(IsAnyLine(7, 8, 9))        {            return true;        }        if(IsAnyLine(1, 5, 9)) // Diagonal -----------------------------------------        {            return true;        }        if(IsAnyLine(7, 5, 3))        {            return true;        }        if(IsAnyLine(1, 4, 7))// Coloumns ------------------------------------------        {            return true;        }        if(IsAnyLine(2, 5, 8))        {            return true;        }        if(IsAnyLine(3, 6, 9))        {            return true;        }        return false;    }Now.... what about all those return true exits from this method. We just need to return true if any of those cases are true. static bool CheckWin() // Win checker method ================================================{    if (IsAnyLine(1, 2, 3) ||        IsAnyLine(4, 5, 6) ||        IsAnyLine(7, 8, 9) ||        IsAnyLine(1, 5, 9) ||        IsAnyLine(7, 5, 3) ||        IsAnyLine(1, 4, 7) ||        IsAnyLine(2, 5, 8) ||        IsAnyLine(3, 6, 9)) return true;    return false;}Oh ... if X==true return true else return false is the same as return X    static bool CheckWin() // Win checker method ================================================    {        return IsAnyLine(1, 2, 3) || // Horizontal                IsAnyLine(4, 5, 6) || // Horizontal                IsAnyLine(7, 8, 9) || // Horizontal                IsAnyLine(1, 5, 9) || // Diagonal               IsAnyLine(7, 5, 3) || // Diagonal               IsAnyLine(1, 4, 7) || // Vertical               IsAnyLine(2, 5, 8) || // Vertical               IsAnyLine(3, 6, 9);   // Vertical    }Now... Interestingly Horizontal lines are all (x,x+1,x+2) and all vertical are (x,x+3,x+6). One diagonal is (x, x+4, x+8) the other is (3, 3+2, 3+4)      private static bool IsAnyHorizontalLine(int startindex)    {        return IsAnyLine(startindex, startindex + 1, startindex + 2);    }    private static bool IsAnyVerticalLine(int startindex)    {        return IsAnyLine(startindex, startindex + 3, startindex + 6);    }    static bool CheckWin() // Win checker method ================================================    {        return IsAnyHorizontalLine(1) ||               IsAnyHorizontalLine(4) ||               IsAnyHorizontalLine(7) ||               IsAnyLine(1, 5, 9) ||               IsAnyLine(7, 5, 3) ||               IsAnyVerticalLine(1) ||               IsAnyVerticalLine(2) ||               IsAnyVerticalLine(3);    }One more thing...     private static bool IsAnyLine(int start, int step)    {        return IsLine(start, start+step, start+step+step, Pos[start]);    }    private static bool IsAnyHorizontalLine(int startindex)    {        return IsAnyLine(startindex, 1);    }    private static bool IsAnyVerticalLine(int startindex)    {        return IsAnyLine(startindex, 3);    }    static bool CheckWin() // Win checker method ================================================    {        return IsAnyHorizontalLine(1) ||               IsAnyHorizontalLine(4) ||               IsAnyHorizontalLine(7) ||               IsAnyLine(1, 4) ||  // Diagonal                IsAnyLine(3, 2) ||  // Diagonal               IsAnyVerticalLine(1) ||               IsAnyVerticalLine(2) ||               IsAnyVerticalLine(3);    }OK we could do more here... but I think this is enough. Let's look at the main logic. Now that is one big function.Lets break out some helper functions... Every time you have a comments I'll make it a function. Same with the body of a loop.. make it a function.    private static string[] EnterPlayers()    {        Console.WriteLine(Hello! This is Tic Tac Toe. If you don't know the rules then stop being an idiot.);        Console.WriteLine(What is the name of player 1?);        var player1 = Console.ReadLine();        Console.WriteLine(Very good. What is the name of player 2?);        var player2 = Console.ReadLine();        Console.WriteLine(Okay good. {0} is O and {1} is X., player1, player2);        Console.WriteLine({0} goes first., player1);        Console.ReadLine();        Console.Clear();        return new [] {player1, player2};    }That makes the first few lines...        string[] players = EnterPlayers();        string player1 = players[0];        string player2 = players[1];Nice. I wonder if a player array is useful? maybe... but lets limit the changes for now and keep using the player variables.In C++ it was good practice to have all your variables declared at the start of the method. In C# we move them to where they are first used. Try for the smallest scope you can for each variable. With that in mind it's also a bad idea to reuse variables. Better to make a new one each time you need it. This decouples code that shouldn't be coupled. This makes changing your code easier. The 'choice' variable is reused each time we ask the user for data. Same with 'correctInput'.while (correctInput == false){     Console.WriteLine(Which position would you like to take?);     choice = int.Parse(Console.ReadLine());     if (choice > 0 && choice < 10)     {         correctInput = true;     } }It's always the same code, so let's make a function.private static int AskTheUser(string prompt){    bool correctInput = false;    int choice = 0;    while (correctInput == false)    {        Console.WriteLine(prompt);        choice = int.Parse(Console.ReadLine());        if (choice > 0 && choice < 3)        {            correctInput = true;        }    }    return choice;}Or simpler... private static int AskTheUser(string prompt, int min, int max){    while (true)    {        Console.WriteLine(prompt);        int choice = int.Parse(Console.ReadLine());        if (choice >= min && choice <= max)        {            return choice;        }    }}... var choice = AskTheUser(Enter your option: , 1, 2);The method is still too big to read... lets pull out  Checks to see if spot is taken already    private static bool TryToPlacePiece(int move, string opponentsPiece, string piece)    {        if (Pos[move] == opponentsPiece) // Checks to see if spot is taken already --------------------        {            Console.WriteLine(You can't steal positions asshole! );            Console.Write(Try again.);            Console.ReadLine();            Console.Clear();            return true;        }        Pos[move] = piece;        return false;    }What would you like to do now?     private static bool AskToPlayAgain()    {        Console.WriteLine(What would you like to do now?);        Console.WriteLine(1. Play again);        Console.WriteLine(2. Leave);        var choice = AskTheUser(Enter your option: , 1, 2);        Console.Clear();        if (choice == 1) return true;        Console.WriteLine(Thanks for playing!);        Console.ReadLine();        return false;    }I did do some code manipulation here... but now it's a method that returns true to keep playing and false otherwise.There are two turns and different logic for each. If we extract a method for the loop, we can see what parameters it needs            while (winFlag == false) // Game loop ------------------------------------------------------            {                if (TakeTurn(player1, score1, player2, score2, turn)) continue;                winFlag = CheckWin();                if (winFlag == false)                {                    if (turn == 1)                    {                        turn = 2;                    }                    else if (turn == 2)                    {                        turn = 1;                    }                    Console.Clear();                }            }Lets look at TakeTurn...    private static bool TakeTurn(string player1, int score1, string player2, int score2, int turn)    {        DrawBoard();        Console.WriteLine();        Console.WriteLine(Score: {0} - {1}     {2} - {3}, player1, score1, player2, score2);        if (turn == 1)        {            Console.WriteLine({0}'s (O) turn, player1);        }        if (turn == 2)        {            Console.WriteLine({0}'s (X) turn, player2);        }        var move = AskTheUser(Which position would you like to take?, 1, 9);        if (turn == 1)        {            if (TryToPlacePiece(move, X, O)) return true;        }        if (turn == 2)        {            if (TryToPlacePiece(move, O, X)) return true;        }        return false;    }The only times 'score1' and 'score2' are used is the first few lines. Lets pull those out    private static void RefreshBoard(string player1, int score1, string player2, int score2)    {        DrawBoard();        Console.WriteLine();        Console.WriteLine(Score: {0} - {1}     {2} - {3}, player1, score1, player2, score2);    }Right.. lets group the 'turn==1' logic.     private static bool TakeTurn(string player1, string player2, int turn)    {        if (turn == 1)        {            Console.WriteLine({0}'s ({1}) turn, player1, O);            var move = AskTheUser(Which position would you like to take?, 1, 9);            if (TryToPlacePiece(move, X, O)) return true;        }        else        {            Console.WriteLine({0}'s ({1}) turn, player2, X);            var move = AskTheUser(Which position would you like to take?, 1, 9);            if (TryToPlacePiece(move, O, X)) return true;        }        return false;    }Pull out the method    private static bool TakeATurn(string player, string playerPiece, string opponentsPiece)    {        Console.WriteLine({0}'s ({1}) turn, player, playerPiece);        var move = AskTheUser(Which position would you like to take?, 1, 9);        return TryToPlacePiece(move, opponentsPiece, playerPiece);    }This seems a lot like it should be inside TryToPlacePiece. So we get... private static bool TryToTakeATurn(string player1, string player2, int turn){    if (turn == 1)    {        if (TryToPlaceAPiece(player1, O, X)) return true;    }    else    {        if (TryToPlaceAPiece(player2, X, O)) return true;    }    return false;}private static bool TryToPlaceAPiece(string player, string playerPiece, string opponentsPiece){    Console.WriteLine({0}'s ({1}) turn, player, playerPiece);    var move = AskTheUser(Which position would you like to take?, 1, 9);    if (Pos[move] == opponentsPiece) // Checks to see if spot is taken already --------------------    {        Console.WriteLine(You can't steal positions asshole! );        Console.Write(Try again.);        Console.ReadLine();        Console.Clear();        return true;    }    Pos[move] = playerPiece;    return false;}Now Main is readable... kinda :)public static void Main(string[] args)    {        string[] players = EnterPlayers();        string player1 = players[0];        string player2 = players[1];        bool playing = true;        int score1 = 0, score2 = 0;        while (playing)        {            bool winFlag = false;            int turn = 1;            while (winFlag == false) // Game loop ------------------------------------------------------            {                RefreshBoard(player1, score1, player2, score2);                if (TryToTakeATurn(player1, player2, turn)) continue;                winFlag = CheckWin();                if (winFlag == false)                {                    turn = turn == 1 ? 2 : 1;                    Console.Clear();                }            }            Console.Clear();            DrawBoard();            ResetBoard();            if (winFlag == false) // No one won ---------------------------            {                Console.WriteLine(It's a draw!);                Console.WriteLine(Score: {0} - {1}     {2} - {3}, player1, score1, player2, score2);                Console.WriteLine();                playing = AskToPlayAgain();            }            if (winFlag) // Someone won -----------------------------            {                if (turn == 1)                {                    score1++;                    Console.WriteLine({0} wins!, player1);                    playing = AskToPlayAgain();                }                if (turn == 2)                {                    score2++;                    Console.WriteLine({0} wins!, player2);                    playing = AskToPlayAgain();                }            }        }    }At this point it's obvious why we are having problem with WinFlag. 'CheckWin' is setting the 'winFlag'. But CheckWin doesn't detect a draw. A draw is reached when there are no more places to put a piece. (or after 9 moves)'TryToPlaceAPiece' also has a problem. It stops you putting a piece on-top of an opponents piece, but not on-top of your own. The biggest smell left if this 'turn' variable. A lot of things are using it as their indicator as to which player is active. Why does the rest of the code care which player is active? The logic should be the same for both. Lets group together all the player specific logic. I'll start by moving it all out of the main method and into helper methods. We can use the players array, and I'll make a score array and put the pieces into an array... then we get     private static void IncrementPlayerScore(int turn, int[] scores)    {        scores[turn-1] = scores[turn - 1]+1;    }    private static void ReportScores(string[] players, int[] scores)    {        Console.WriteLine(Score: {0} - {1}     {2} - {3}, players[0], scores[0], players[1], scores[1]);    }    private static string GetPlayer(int turn, string[] players)    {        return players[turn - 1];    }    private static string GetPlayerPiece(int turn, string[] pieces)    {        return pieces[turn - 1];    }    private static int NextTurn(int turn)    {        return 3 - turn;    }These helpful methods.OK  This is getting way too long... lets jump some steps.    public static void Main(string[] args)    {        string[] players = EnterPlayers();        string[] pieces = {O, X};        int[] scores = {0, 0};        bool playing = true;        while (playing)        {            PlayGame(players, scores, pieces);            playing = AskToPlayAgain();        }    }This is what Main looks like now. We are using 'turn-1' as a player index in the player array, scores array and pieces array. We might as well change turn to be 0 based, to remove the logic. So... here is the final code... in totalclass Program{    // Array that contains board positions, 0 isnt used --------------------------------    private static readonly string[] Pos = { 0, 1, 2,3,4,5,6,7,8,9 };    private static void DrawBoard() // Draw board method ==========================================    {        Console.WriteLine(   {0}  |  {1}  |  {2}   , Pos[1], Pos[2], Pos[3]);        Console.WriteLine(-------------------);        Console.WriteLine(   {0}  |  {1}  |  {2}   , Pos[4], Pos[5], Pos[6]);        Console.WriteLine(-------------------);        Console.WriteLine(   {0}  |  {1}  |  {2}   , Pos[7], Pos[8], Pos[9]);    }    private static string[] EnterPlayers()    {        Console.WriteLine(Hello! This is Tic Tac Toe. If you don't know the rules then stop being an idiot.);        Console.WriteLine(What is the name of player 1?);        var player1 = Console.ReadLine();        Console.WriteLine(Very good. What is the name of player 2?);        var player2 = Console.ReadLine();        Console.WriteLine(Okay good. {0} is O and {1} is X., player1, player2);        Console.WriteLine({0} goes first., player1);        Console.ReadLine();        Console.Clear();        return new [] {player1, player2};    }    public static void Main(string[] args)    {        string[] players = EnterPlayers();        string[] pieces = {O, X};        int[] scores = {0, 0};        bool playing = true;        while (playing)        {            PlayGame(players, scores, pieces);            playing = AskToPlayAgain();        }    }    private static void PlayGame(string[] players, int[] scores, string[] pieces)    {        bool isGameWon = false;        bool isGameOver = false;        int playerIndex = 0;        while (isGameOver == false)        {            var nextPlayerIndex = 1 - playerIndex;            var player = players[playerIndex];            var piece = pieces[playerIndex];            var opponentPiece = pieces[nextPlayerIndex];            PlayerMakesAMove(players, scores, player, piece, opponentPiece);            isGameWon = CheckWin();            isGameOver = isGameWon || CheckDraw();            if (isGameOver == false)            {                playerIndex = nextPlayerIndex;            }        }        Console.Clear();        DrawBoard();        ResetBoard();        if (isGameWon) // Someone won -----------------------------        {            IncrementPlayerScore(scores, playerIndex);            Console.WriteLine({0} wins!, players[playerIndex]);        }        else // No one won ---------------------------        {            Console.WriteLine(It's a draw!);        }        ReportScores(players, scores);    }    private static void PlayerMakesAMove(string[] players, int[] scores, string player, string piece, string opponentPiece)    {        do        {            Console.Clear();            DrawBoard();            Console.WriteLine();            ReportScores(players, scores);        } while (!TryToPlaceAPiece(player, piece, opponentPiece));    }    private static bool CheckDraw()    {        // TODO        return false;    }    private static void IncrementPlayerScore(int[] scores, int playerIndex)    {        scores[playerIndex] = scores[playerIndex] + 1;    }    private static void ReportScores(string[] players, int[] scores)    {        Console.WriteLine(Score: {0} - {1}     {2} - {3}, players[0], scores[0], players[1], scores[1]);    }    private static bool TryToPlaceAPiece(string player, string playerPiece, string opponentsPiece)    {        Console.WriteLine({0}'s ({1}) turn, player, playerPiece);        var move = AskTheUser(Which position would you like to take?, 1, 9);        if (!IsMoveTaken(playerPiece, opponentsPiece, move))        {            Pos[move] = playerPiece;            return true;        }        Console.WriteLine(That positions is taken dude! );        Console.Write(Try again.);        Console.ReadLine();        Console.Clear();        return false;    }    private static bool IsMoveTaken(string playerPiece, string opponentsPiece, int move)    {        return Pos[move] == opponentsPiece || Pos[move] == playerPiece;    }    private static bool AskToPlayAgain()    {        Console.WriteLine();        Console.WriteLine(What would you like to do now?);        Console.WriteLine(1. Play again);        Console.WriteLine(2. Leave);        var choice = AskTheUser(Enter your option: , 1, 2);        Console.Clear();        if (choice == 1) return true;        Console.WriteLine(Thanks for playing!);        Console.ReadLine();        return false;    }    private static int AskTheUser(string prompt, int min, int max)    {        while (true)        {            Console.WriteLine(prompt);            int choice = int.Parse(Console.ReadLine());            if (choice >= min && choice <= max)            {                return choice;            }        }    }    private static void ResetBoard()    {        for (int i = 1; i < 10; i++)        {            Pos[i] = i.ToString();        }    }    static bool CheckWin() // Win checker method ================================================    {        return IsAnyHorizontalLine(1) ||               IsAnyHorizontalLine(4) ||               IsAnyHorizontalLine(7) ||               IsAnyLine(1, 4) ||  // Diagonal               IsAnyLine(3, 2) ||  // Diagonal               IsAnyVerticalLine(1) ||               IsAnyVerticalLine(2) ||               IsAnyVerticalLine(3);    }    private static bool IsLine(int index0, int index1, int index2, string piece)    {        return Pos[index0] == piece && Pos[index1] == piece && Pos[index2] == piece;    }    private static bool IsAnyLine(int start, int step)    {        return IsLine(start, start+step, start+step+step, Pos[start]);    }    private static bool IsAnyHorizontalLine(int startindex)    {        return IsAnyLine(startindex, 1);    }    private static bool IsAnyVerticalLine(int startindex)    {        return IsAnyLine(startindex, 3);    }}The goal here was to make the code more readable. You want to go from not obviously wrong to Obviously not wrong. Having small methods that show your intent and encapsulate your implementation decisions does this for you. So.... using the squint test again... The biggest method is somewhat manageable.Taking this further... C# is Object Oriented. You can use these features to separate the code into blocks each with it's own single responsibility. Some examples: a Board Object that knows how to draw itself and detect lines. A Player object that knows it's score, name and what piece it is using.A Game object that knows the flow of a game.A Tournament object that knows how to start new games if people want to keep playing.We can give that a go I you want more feedback. Good luck!