C# resize an array of unknown type -


possible duplicate:
c#: there way resize array of unknown type using reflection?

hi,

is there way resize array of unknown type? please see sample code below.

object readarray() {     type classtype = type.gettype(arrayitemname, true);     object arr = array.createinstance(classtype, 0); // unknown length      // read length stream     resizearray(ref arr, length)     // populate array items stream      // read length2  stream2     resizearray(ref arr, length+length2)     // populate array items stream2      return arr; }  resizearray(ref object array, int n) {     array arr = array array;     array.resize(ref arr, n); // compile error! type can't inferred     array = arr; } 

use generic list. not have problem resizing.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -