Skip to content

Instantly share code, notes, and snippets.

@mstum
Created December 7, 2012 08:26
Show Gist options
  • Save mstum/4231781 to your computer and use it in GitHub Desktop.
Save mstum/4231781 to your computer and use it in GitHub Desktop.
Ugly yield return
private static IEnumerable<byte> Add(byte register, int value)
{
yield return Opcodes.Add.Code;
yield return register;
foreach (var bt in WriteInt(value)) yield return bt;
}
private static IEnumerable<byte> WriteInt(int value)
{
yield return (byte)(value >> 24);
yield return (byte)(value >> 16);
yield return (byte)(value >> 8);
yield return (byte)(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment