Skip to content

Instantly share code, notes, and snippets.

@codereflection
Created October 24, 2011 19:33
Show Gist options
  • Save codereflection/1309922 to your computer and use it in GitHub Desktop.
Save codereflection/1309922 to your computer and use it in GitHub Desktop.
Alternative to C#'s out and Tuples
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));
}
}
}
@codereflection
Copy link
Author

NOTE: This is a stupid example. I could have come up with a better one, but I'm lacking creativity at the moment.. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment