Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created February 19, 2014 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/9103821 to your computer and use it in GitHub Desktop.
Save controlflow/9103821 to your computer and use it in GitHub Desktop.
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