473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Casting Object into string[ ]?(Repost)

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.

Nov 15 '05 #1
3 10109
> My basic question:
How do I cast an object into a string []?


Have you tried this:

string []arr = (string [])theObject;

That should work,
-JG
Nov 15 '05 #2
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
"Nathan" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
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.

Nov 15 '05 #3
"Nathan" <an*******@discussions.microsoft.com> wrote in news:053801c398ed
$0****************@phx.gbl:
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;

--
best regards

Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kurt Lange | last post by:
no... the array is created dynamically. and no... that defeats the purpose of what im trying todo.. encapsulate all initializing of variables in base class... derive from it... by deriving...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
23
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than...
31
by: dragoncoder | last post by:
Consider the code class A { private: int a; }; int main(void) { A x; int* ptr = (int*)&x;
2
by: Giulio Petrucci | last post by:
Hi everybody, here's my problem: I have to dymanically build (and compile, of course) some code, from some ECMAScript function. ECMAScript variables I get are not typezed, so I should have...
7
by: S. Lorétan | last post by:
Hi guys, Sorry for this stupid question, but I don't know why it isn't working. Here is my (example) code: namespace Test { class A { public string Label1; }
29
by: Tony Johansson | last post by:
Hello! Here I have two different way to use casting. Is any of these any better then the other? Or is it just a question of taste. newCards.Add((Card)sourceCard.Clone());...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.