This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace TicTacToe_OO // object oriented implementation of tic tac toe | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
while (true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Vector2D v1 = new Vector2D(3, 4); | |
Console.WriteLine(v1); | |
Vector2D v2; | |
v2.x = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.Write("Enter name of method to be called (Method1 or Method2): "); | |
string methodName = Console.ReadLine(); | |
MethodInfo methodInfo = typeof(Program).GetMethod(methodName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TicTacToeHumanVsMachineBruteForce | |
{ | |
class Program | |
{ | |
static char[] cells; | |
static Random rand = new Random(); | |
static void Main() | |
{ | |
int numberXWins = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Output: | |
// First 10 fibonacci numbers: | |
// 0 1 1 2 3 5 8 13 21 34 | |
class First10FibonacciNumbers | |
{ | |
static void Main() | |
{ | |
int previous = 0; | |
int current = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here are two programs (client and server) that talk via tcp/ip over a socket connection. | |
1. Run the server side program first and note the ip address of the machine that it is running on. | |
2. Then run the client and enter the ip address of the server. | |
3. Finally enter a message and hit enter. The message is sent to the server, reversed, and then sent back to the client. | |
/////////////////// | |
// TCP Client | |
using System; | |
using System.Net.Sockets; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Thread[] threadArray = new Thread[8]; | |
(threadArray[0] = new Thread(ThreadFunc)).Start(ConsoleColor.Red); | |
(threadArray[0] = new Thread(ThreadFunc)).Start(ConsoleColor.Yellow); | |
(threadArray[0] = new Thread(ThreadFunc)).Start(ConsoleColor.Magenta); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Pig Dice"); | |
Game game = new Game(); | |
game.Play(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
for (int i = 0; i < 20; i++) | |
{ | |
object value = GetValueFromSomewhere(); | |
switch (value) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
int num = 10; | |
Console.WriteLine(AddUpToLoop(num)); | |
Console.WriteLine(AddUpToRecursive(num, 0)); | |
Func<int, int, int> AddUpToLambda = null; | |
AddUpToLambda = (num, sum) => { return num == 0 ? sum : AddUpToLambda(--num, sum + num + 1); }; |