Created
February 19, 2014 23:30
-
-
Save controlflow/9103821 to your computer and use it in GitHub Desktop.
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
sealed class ArrayPart : Part | |
{ | |
readonly int myArrayLength; | |
readonly object[] myArray; | |
int myItemIndex; | |
public ArrayPart(int arrayLength) | |
{ | |
myArray = new object[arrayLength]; | |
myArrayLength = arrayLength; | |
myItemIndex = 0; | |
} | |
public override object Value | |
{ | |
get { return myArray; } | |
} | |
public override void PutMember(object value) | |
{ | |
if (myItemIndex < myArrayLength) | |
{ | |
myArray[myItemIndex] = value; | |
myItemIndex++; | |
} | |
} | |
} | |
// => | |
sealed class ArrayPart(int arrayLength) : Part | |
{ | |
readonly object[] myArray = new object[arrayLength]; | |
int myItemIndex = 0; | |
public override object Value => myArray; | |
public override void PutMember(object value) | |
{ | |
if (myItemIndex < arrayLength) | |
{ | |
myArray[myItemIndex] = value; | |
myItemIndex++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment