Created
October 24, 2011 19:33
-
-
Save codereflection/1309922 to your computer and use it in GitHub Desktop.
Alternative to C#'s out and Tuples
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
using System; | |
namespace TuplesSuck | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var returnedCount = 0; | |
var returnedString = ""; | |
InitString('c', 100, (count, seed) => | |
{ | |
returnedCount = count; | |
returnedString = seed; | |
}); | |
Console.WriteLine("Returned Count: {0}", returnedCount); | |
Console.WriteLine("Returned string: {0}", returnedString); | |
Console.ReadKey(); | |
} | |
private static void InitString(char seedChar, int howMany, Action<int, string> result) | |
{ | |
result.Invoke(howMany, new string(seedChar, howMany)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This is a stupid example. I could have come up with a better one, but I'm lacking creativity at the moment.. :P