Skip to content

Instantly share code, notes, and snippets.

View droyad's full-sized avatar

Robert Wagner droyad

View GitHub Profile
double x = 0;
while(x != 30)
x += 0.3;
System.Console.WriteLine("Done: " + x);
double n = 0;
for(int x = 0; x < 20; x++)
{
n+= 0.3;
}
n.Dump();
(n == 6.0).Dump();
((0.3 * 20) == 6.0).Dump();
Stream stream = null;
try
{
stream = new FileStream("file.txt", FileMode.OpenOrCreate);
using (StreamWriter writer = new StreamWriter(stream))
{
stream = null;
// Use the writer object...
}
}
using (Stream stream = new FileStream("file.txt", FileMode.OpenOrCreate))
{
using (StreamWriter writer = new StreamWriter(stream))
{
// Use the writer object...
}
}
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<!-- These can go into the global styles-->
<Style TargetType="{x:Type Label}">
<Setter Property="TextBlock.TextAlignment" Value="Right" />
<Setter Property="Margin" Value="5,5,10,5" />
</Style>
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<!-- These can go into the global styles-->
<Style TargetType="{x:Type Label}">
<Setter Property="TextBlock.TextAlignment" Value="Right" />
<Setter Property="Margin" Value="5,5,10,5" />
<Setter Property="Height" Value="30" />
4000000000000000000000001d-4000000000000000000000000d
4000000000000000000000001m-4000000000000000000000000m
// Not written in an IDE
class MyViewModel
{
MyViewModelStepEnum CurrentStep { get; set; }
enum MyViewModelStepEnum {
Step 1, Step2
}
}
private struct Entry
{
public int hashCode;
public int next;
public TKey key;
public TValue value;
}
private Dictionary<TKey, TValue>.Entry[] entries;
private int[] buckets;
@droyad
droyad / gist:4527604
Created January 14, 2013 03:35
Support for NUnit's TestCase attribute
public class NUnitTestCaseStackTraceParser : AttributeStackTraceParser
{
protected override string GetAttributeType()
{
return typeof(TestCaseAttribute).FullName;
}
public override string ForTestingFramework
{