Casting Object into string[ ]?(Repost)

  • Thread starter Thread starter Juan Gabriel Del Cid
  • Start date Start date
Hi:

Here's what I am trying to do, pass a string array between
two pages using Server.Transfer method:
Sending page I do this:
private string[] arrFCInfo=new String[5];
//Property - read only public
public object arrayFC
{
get
{
return arrFCInfo;
}
}

In the receiving page, I want to get the string array from
the object.

My basic question: How do I cast an object in to a string
[]?

Thanks in advance.
 
To cast to a string[] simply cast it. string[] var = (string[])obj.arrayFC;

Or try the as syntax, it's a little more graceful than a try-catch block
should you need it.

string[] var = obj.arrayFC as string[];
if (var != null)
{
// do something
}


HTH;
Eric Cadwell
http://www.origincontrols.com
 
Hi:

Here's what I am trying to do, pass a string array between
two pages using Server.Transfer method:
Sending page I do this:
private string[] arrFCInfo=new String[5];
//Property - read only public
public object arrayFC
{
get
{
return arrFCInfo;
}
}

In the receiving page, I want to get the string array from
the object.

My basic question: How do I cast an object in to a string
[]?

Thanks in advance.

string[] something = new string[5];

object obj = (object)something;

string[] anotherthing = (string[])obj;
 
Back
Top