473,387 Members | 1,859 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,387 software developers and data experts.

Arraylist toArray null elements

I have an arraylist which has 0 number of elements. When i cast it to a string[] array, what happens ? Will my string[] be a "null" value, or will I get a ArgumentNullException ?

eg.

ArrayList al = new ArrayList();
String[] myAr = null;
......
............

myAr = (String[])al.ToArray(typeof(string));
return myAr;

cheers
Andrew
Jul 28 '08 #1
2 1565
r035198x
13,262 8TB
Best way to learn this is to try it on the compiler and see for yourself what happens.
Jul 28 '08 #2
Plater
7,872 Expert 4TB
My guess would be you would get a string[] of size 0
Jul 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Christopher Pragash | last post by:
Hello all, I'm trying to persist an object of type Arraylist into XML using the following the XMLSerializer and it returns an "Unknown" Error. I'm able to serialize and deserialize the arraylist...
2
by: Sunny | last post by:
Hi, I have a small function, that returns a string, inside the function, there is an arraylist, being processed. At the end of the function all the elements of the ArrayList are copied to my...
4
by: Derrick | last post by:
If i have an ArrayList, add a bunch of MyClass classes to it, how do I get a MyClass out of it? I've tried: MyClass clses = ArrayList.ToArray(typeof(MyClass)); but get errors about not being...
4
by: Hans De Schrijver | last post by:
I have a private ArrayList variable that holds objects of various types, though they're all derived from a common base class (User). What I would like to do is provide public accessor properties...
3
by: kevin | last post by:
I need to join the elements of an arraylist into a comma delimited list and have been doing the following string x = new string; myArrayList.CopyTo(x); string.join(",",x); I tried...
2
by: Dirk | last post by:
Hello The following code does not work ArrayList __gc* allControls = new ArrayList(); ..... // put some Controls in allControls .... Control __gc* arr = dynamic_cast<Control...
2
by: Russ Green | last post by:
I am currently working on a small VB.NET utility that accesses the Microstation VBA object model via COM. I have this code which I am trying to get to work... The key bits of information are ...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
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:
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: 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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.