If I have an array of [Object]'s, all of the same type (say [String] for
example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if
there a conversion class within the framework or VB statement that makes
this quick and simple.
Cheers everyone.
--
===
Phil
(Auckland | Aotearoa) 9 10069
Phil,
You mean something as this?
Dim a() As Object = {"You", "never", "know", "why"}
MessageBox.Show (DirectCast(a(2 ), String))
I do not know a method to make a deep copy in one time and never saw it
although it is more time asked in this newsgroup.
Cor If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if there a conversion class within the framework or VB statement that makes this quick and simple.
Cheers everyone.
-- === Phil (Auckland | Aotearoa)
Phil,
You mean something as this?
Dim a() As Object = {"You", "never", "know", "why"}
MessageBox.Show (DirectCast(a(2 ), String))
I do not know a method to make a deep copy in one time and never saw it
although it is more time asked in this newsgroup.
Cor If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if there a conversion class within the framework or VB statement that makes this quick and simple.
Cheers everyone.
-- === Phil (Auckland | Aotearoa)
"Phil Jones" <ph************ @hotmail.com> schrieb: If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
<URL: http://groups.google.de/groups?selm=...2MSFTNGP11.phx
..gbl>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Phil Jones" <ph************ @hotmail.com> schrieb: If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
<URL: http://groups.google.de/groups?selm=...2MSFTNGP11.phx
..gbl>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Please don't multi-post. You could have cross-posted this instead to
whatever groups you wanted the question to appear in.
Here's your VB version (for reference types):
Dim str() As String = DirectCast(objA rray, String())
Note that objArray is an object array which contains string elements. Again,
this won't work for value types. You can either use Array.Copy or cast each
element individually.
Dim iArray(objIntAr ray.Length - 1) As Integer
Array.Copy(objI ntArray, iArray, objIntArray.Len gth)
hope that helps..
Imran.
"Phil Jones" <ph************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if there a conversion class within the framework or VB statement that makes this quick and simple.
Cheers everyone.
-- === Phil (Auckland | Aotearoa)
Sorry dude. What do you mean by "cross-posted"? Is that putting all the
groups within the address of one message?
Thanks for the VB version! And thank you everyone else who responded.
--
===
Phil
(Auckland | Aotearoa)
"Imran Koradia" <no****@microso ft.com> wrote in message
news:uP******** ******@TK2MSFTN GP15.phx.gbl... Please don't multi-post. You could have cross-posted this instead to whatever groups you wanted the question to appear in.
Here's your VB version (for reference types):
Dim str() As String = DirectCast(objA rray, String())
Note that objArray is an object array which contains string elements. Again, this won't work for value types. You can either use Array.Copy or cast each element individually.
Dim iArray(objIntAr ray.Length - 1) As Integer Array.Copy(objI ntArray, iArray, objIntArray.Len gth)
hope that helps.. Imran.
"Phil Jones" <ph************ @hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. If I have an array of [Object]'s, all of the same type (say [String] for example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if there a conversion class within the framework or VB statement that makes this quick and simple.
Cheers everyone.
-- === Phil (Auckland | Aotearoa)
> Sorry dude. What do you mean by "cross-posted"? Is that putting all the groups within the address of one message?
Yes
"Phil Jones" <ph************ @hotmail.com> schrieb: Sorry dude. What do you mean by "cross-posted"? Is that putting all the groups within the address of one message?
Yes, but /only/ post the question to relevant groups (three groups at max.).
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: rihad |
last post by:
Hi, I've this question: suppose we have two differently typed pointers:
struct foo *foo;
char **array;
Becase one can always legally cast any pointer to (void *), and becase (void *)
is assignable to any pointer type, is it ever necessary to cast when assigning
one pointer type to another? I.e. since
foo = (void *) array;
|
by: Brian Blais |
last post by:
Hello,
I saw on a couple of recent posts people saying that casting the return
value of malloc is bad, like:
d=(double *) malloc(50*sizeof(double));
why is this bad? I had always thought (perhaps mistakenly) that the
purpose of a void pointer was to cast into a legitimate date type. Is
this wrong? Why, and what is considered to be...
|
by: Kurzweil |
last post by:
I need to make a two dimensional array of objects. These objects are of type
Influence.
How do I declare such an array?
Now I use:
private object influences;
influences = GetInfluences(); // GetInfluences returns type
Influence
But when I need to use something from te array I have to typecast from
|
by: Fabrizio |
last post by:
Hi
I cannot figure why it isn't possible to cast a struct array to an object
array.
I written a structure like this:
public struct Test {
private int TestA;
private int TestB;
|
by: Barry Mossman |
last post by:
Hi,
I get the feeling that I am missing something with regards to casting.
The CopyTo method allows me to copy the contents of a collection into an
array. My collection is a MatchCollection produced by Regex. The
Collection's entries are all valid strings. If I CopyTo to a string array
it compiles ok, but fails at run time with an...
| |
by: Jon the Blind |
last post by:
I have a set of business object classes built from the typed dataset tool in
Visual Studio. Since the individual objects (such as the Order object, for
example) inherit from DataRow, a common requirement is to cast an array of
DataRows to an array of Orders. But I keep getting InvalidCastExceptions
when I do this, for example:
Dim orders As...
|
by: Phil Jones |
last post by:
If I have an array of 's, all of the same type (say for
example).
Is there a quick way to cast that to a typed String array?
Presently I'm having to copy each object to a new array. I'm wondering if
there a conversion class within the framework or VB statement that makes
this quick and simple.
Cheers everyone.
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from that array
Could you show me a little example how to do this?
Thanks.
|
by: conchur |
last post by:
Is there an elegant way to have a class utilise an inherited method to
return a Typed Collection of itself?
Example:
class MyList<T> : List<T> where T : MyRoot
{
Add...
Remove...
}
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |