Created
December 7, 2012 08:26
-
-
Save mstum/4231781 to your computer and use it in GitHub Desktop.
Ugly yield return
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
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