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
// Starting and Stopping midi playback on multiple threads | |
using System; | |
using System.Threading; | |
using Melanchall.DryWetMidi.Devices; | |
using Melanchall.DryWetMidi.Smf; | |
class Program | |
{ | |
public static Playback playback; | |
static void Main() | |
{ |
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.Collections.Generic; | |
using System.Timers; | |
class Program | |
{ | |
static List<Bot> bots = new List<Bot>(); | |
static void Main() | |
{ | |
Console.CursorVisible = false; |
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.Collections.Generic; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<Tuple<string, string>> list = new List<Tuple<string, string>>(); | |
list.Add(new Tuple<string, string>("fruit", "apple")); | |
list.Add(new Tuple<string, string>("fruit", "peach")); | |
list.Add(new Tuple<string, string>("vegetable", "carrot")); |
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.Collections.Generic; | |
class Program | |
{ | |
static void Main() | |
{ | |
{ | |
var nums = GetArrayOfFirstTenIntegers(); | |
foreach (int n in nums) | |
{ |
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); }; |
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(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; | |
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
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
// 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; |
NewerOlder