Created
January 8, 2011 16:13
-
-
Save jagregory/770942 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
public class Task<T> | |
{ | |
readonly T something; | |
public Task(T something) | |
{ | |
this.something = something; | |
} | |
} | |
public static class Task | |
{ | |
public static Task<T> New<T>(T something) | |
{ | |
return new Task<T>(something); | |
} | |
} |
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
// find myself using this "pattern" a lot to avoid the rather irritating inability of the C# compiler to infer generic arguments from constructor arguments | |
var something = "value"; | |
var task = Task.New(something); | |
// instead of: | |
var something = "value"; | |
var task = new Task<string>(something); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment