473,811 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count.ToString in ArrayList

I donot understand why it is this way.

I have an arraylist.

I understand I can get the count by arraylist.count

in .net studio, intellisense also gives me arraylist.count .tostring()
Nov 16 '05 #1
4 9224
COunt is an integer so MessageBox.Show (arraylist.Coun t); won't compile. If
you want to show what it is, you need to convert it to string and ToString()
is a good way to do it. Depending on the situation, you may need it in some
other form other than int.
"Krish" <sk*******@snet .net> wrote in message
news:87******** *************** ***@posting.goo gle.com...
I donot understand why it is this way.

I have an arraylist.

I understand I can get the count by arraylist.count

in .net studio, intellisense also gives me arraylist.count .tostring()

Nov 16 '05 #2
Hi Krish,

What do you not understand?

An ArrayList is a linked list that can grow and shrink in size when needed.
The ArrayList has a Count property that returns the number of items
"inside" the list.
This number is of type 'int', and the ToString() method will convert it to
'string'.

ArrayList myList = new ArrayList.

int numberInt = myList.Count; // returns 0
string numberString = myList.Count.To String(); // returns "0";

myList.Count.To String(); // is the same as
(myList.Count). ToString(); // which in this example is the same as
numberInt.ToStr ing();

It would be much easier to help you if you can give us a clear question.
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
Morten Wennevik <Mo************ @hotmail.com> wrote:
An ArrayList is a linked list that can grow and shrink in size when needed.


No, an ArrayList is *not* a linked list. It's a list backed by an
array. It can grow and shrink in size when needed - if it exceeds the
bounds of the internal array, a new array is created and the contents
of the old one copied. That is all hidden from the client, however.

<snip stuff I agree with>

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Ah, noted.
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #5

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

Similar topics

0
2183
by: kovac | last post by:
The System.directoryservices.dll has an error, and this error was described in http://support.microsoft.com/default.aspx?scid=kb;en-us;839424 At the moment we have Framework version v1.0.3705 and I have remove System.directoryservices.dll from current Framework version v1.0.3705. In state of old version I load die new System.directoryservices.dll from the Framework version v1.1.4322. I work with the following function of Joe Kaplan...
2
2099
by: Niklas E | last post by:
Does anyone know how to get all nodes in a xml-document that start with a certain text? In my case I want to count all suppliers ( <id>Supplier*</id> ) <root> <customer> <name>ABC</name> <id>Supplier123</id> </customer>
9
10851
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using LDIFDE as a comparison I get the same results. No members means just that, an empty group. Zero means that the DirectorySearcher.SizeLimit has been exceeded....
2
2694
by: Dan =o\) | last post by:
Hey guys, I'm getting really annoyed with this array... After selecting some items from a list view, I take the selected text from the first column and store it in an array, I then pass this data back to the parent of this window, which then takes this list (of filenames) and downloads them to a scanner. I step through the child's array being filled with some paths of the data that I selected in my list, then it all goes pear shaped....
2
3314
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
2
1326
by: Jon | last post by:
Hello all, I think I must be missing something here as it seems it should be simple, but I've just tried to do a 'arrExtRep.ToString() (where arrItems is an ArrayList) and I get the error: error: 'arrExtRep.ToString' does not exist, however arrExtRep kicks out the value; Why's that and how can i overcome it?
3
3879
by: Eric Cathell | last post by:
I am using an arraylist to process data....the unique problem i have run into is that if I delete one of the indexed values the arraylist is reindexed and i get an exception thrown. I need to start at the last item in the arraylist and go backwards....a for next loop doesnt seem to let me do this... for i =arraylist.count-1 to 0 'do stuff here next
5
1833
by: colin | last post by:
some enumerable types like collections use Count but but other enumerable types like arrays use length why the difference? Im not sure what my function is going to be passed yet, some enumerable type such as an array or a list, but I need to allocate space first, so I need to know how big it is, so I need to use ICollection as a parameter type. luckily arrays have ICollection as a base too, so why do arrays have
18
3441
by: Tony | last post by:
Hello! I have an ArrayList with many double that is sorted some of these double value exist more then once in the ArrayList. Is it possible to use some feature in C# or from the framework to count each unique double value or is the only solution to run through the list and count every unique double value. //Tony
0
9605
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5555
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.