public static ListOfFoo <T> FromBytes(byte[] bytes, ref int index) { var count = bytes[index++]; var listOfFoo = new ListOfFoo <T>(); for (var i = 0; i < count; i++) { listOfFoo.Add(BytesFromFunc(bytes, ref index)); } return(listOfFoo); }
public static ListOfFoo <T> FromBytes(byte[] bytes, ref int index) { var count = bytes[index++]; var listOf = new ListOfFoo <T>(); for (var i = 0; i < count; i++) { var o = dic[typeof(T)](bytes, index); listOf.Add((T)o.Value); index = o.Index; } return(listOf); }
public static ListOfFoo <T> FromBytes(byte[] bytes, ref int index) { // create dummy instance for accessing static method via instance method T dummy = new T(); var count = bytes[index++]; var listOfFoo = new ListOfFoo <T>(); for (var i = 0; i < count; i++) { // instead of calling the static method, // call the instance method on the dummy instance listOfFoo.Add(dummy.FromBytes(bytes, ref index)); } return(listOfFoo); }