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
var @null = "HEY"; | |
var @if = "WHAT R U DOIN"; | |
var @object = "PLZ STAHP"; | |
Console.WriteLine(String.Format("{0} {1} {2}", @null, @if, @object)); |
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
var @switch = new Dictionary<Type, Action> | |
{ | |
{typeof(CSharp), () => | |
{ | |
Console.WriteLine("<3"); | |
}}, | |
{typeof(Rainbow), () => | |
{ | |
Console.WriteLine("20% Cooler"); | |
}}, |
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
[Flags] | |
public enum Powers : byte | |
{ | |
Speed = 1, | |
Looks = 1 << 1, | |
Money = 1 << 2, | |
Smart = 1 << 3, | |
None = 1 << 4 | |
} |
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
var hero = (Superhero)42; | |
var powers = Powers.Looks | Powers.Money | Powers.Smart |
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
public static class SuperheroEx | |
{ | |
public static string Name(this Superhero superhero) | |
{ | |
return Enum.GetName(typeof(Superhero), superhero); | |
} | |
} |
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
public class HeroWithPowers | |
{ | |
public Superhero Hero {get; set;} | |
public Powers Powers {get; set;} | |
} | |
void Main() | |
{ | |
var heros = new List<HeroWithPowers> | |
{ |
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
var numsToRound = new []{0.5, 1.5, 2.5, 3.5, 4.5}; | |
Console.WriteLine("Banker|Away|Convert|Cast"); | |
foreach(var num in numsToRound) | |
{ | |
var toEven = Math.Round(num); | |
var awayFromZero = Math.Round(num, MidpointRounding.AwayFromZero); | |
var convert = Convert.ToInt32(num); | |
var cast = (int)num; | |
Console.WriteLine(String.Format(" {0} | {1} | {2} | {3} ", toEven, awayFromZero, convert, cast)); |
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
Banker|Away|Convert|Cast | |
0 | 1 | 0 | 0 | |
2 | 2 | 2 | 1 | |
2 | 3 | 2 | 2 | |
4 | 4 | 4 | 3 | |
4 | 5 | 4 | 4 |
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
void Main() | |
{ | |
var boyfriends = new List<Boyfriend> | |
{ | |
new Boyfriend | |
{ | |
LovesMe = true, | |
LovesMeNot = false, | |
EntriesOnRapSheet = int.MaxValue, | |
Name = "Ima Baddude" |
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
void Main() | |
{ | |
var answer = new ThisIsTrue(); | |
if(answer) | |
Console.WriteLine("Paradox ain't nuthin for .NET"); | |
} | |
public class ThisIsTrue | |
{ |
OlderNewer