Skip to content

Instantly share code, notes, and snippets.

@markushaslinger
Created March 22, 2018 14:39
Show Gist options
  • Save markushaslinger/da8856c063c15e5934d0e50bea71aaf7 to your computer and use it in GitHub Desktop.
Save markushaslinger/da8856c063c15e5934d0e50bea71aaf7 to your computer and use it in GitHub Desktop.
class Program
{
public static void Main()
{
TimeSpan timeSpan;
Foo foo;
Bar bar;
//Baz baz;
TryTimeSpan(out timeSpan);
TryFoo(out foo);
TryBar(out bar);
//TryBaz(out baz);
Console.WriteLine(timeSpan);
Console.WriteLine(foo);
Console.WriteLine(bar);
}
private static bool TryTimeSpan(out TimeSpan timeSpan)
{
// no compile error!
return false;
}
private static bool TryFoo(out Foo foo)
{
return false;
}
private static bool TryBar(out Bar bar)
{
return false;
}
/*
private static bool TryBaz(out Baz baz)
{
// compile error, baz not assigned
return false;
}
*/
}
struct Foo { }
struct Bar
{
public TimeSpan TimeSpan { get; set; }
}
struct Baz
{
public int Int { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment