Created
March 22, 2018 14:39
-
-
Save markushaslinger/da8856c063c15e5934d0e50bea71aaf7 to your computer and use it in GitHub Desktop.
This file contains 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
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