How do you convert int[,] into object[,]?

I've got 3 questions. Need help please,

1. I have a multidimension integer[5,3]  that needed to be converted into object[5,3].

Is there any best way of doing it

2. What is the best/common practice of searching a record (to see if it existed)

a)  using executescalar() and what is the object that it returns

b) any other suggestion

3. What is a safearray for Can anybody give me a simple example to demonstrate how to use safearray and its benefit

Thanks in advance!



Answer this question

How do you convert int[,] into object[,]?

  • KAAU

    Thanks for the reply,

    I thought there was a simple way such as object[]=int[];

    I'm new to this C#. language.

    I find a lot of ways to search a record in a database. The one that I just knew is by using ExecuteScalar(). Do you think this is the best/common way of searching a record in a dbo or there are other better ways

    Thanks


  • Jeff3464

    no no no. Cast the thing.

  • Marco Minerva

    Thanks Matt,

    Is this what you meant   it doesnt work or there is a mistake in the following code

    int[,] sourceIntArray=new int[3,5];

    // filled up the array

    object[,] targetObjArray=new object[3,5];

    targetObjArray=(object[,])sourceIntArray;


  • jaramillo

    1: How about the most obvious solution

    int[,] ints = ...

    object[,] objs = new object[5,3];

    for (int i = 0: i < 5; i++) for (int j = 0; j < 3; j++) objs[i, j] = ints[i, j];

    2: Not sure I understand the question.

    3: A SAFEARRAY is a self describing array type used in the world of COM and OLE automation.



  • How do you convert int[,] into object[,]?