C#: returns array from object.

Posted by jitm on Stack Overflow See other posts from Stack Overflow or by jitm
Published on 2010-06-03T11:47:15Z Indexed on 2010/06/03 11:54 UTC
Read the original article Hit count: 253

Filed under:
|
|

Hello, There is the next task: I need to check if input parameter (object) is array, then return array of input elements. For example I have input array like this:

int [] array = {1,2,3,4};

And method

  private object[] GetArray(object @from)
  {
  }

So, I need to check in this method that input variable is array and after return this array. For checking I use

if(@from.GetType().IsArray)

And how to create array from object ??? Is it possible ? Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays