[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why cant i use arraylist.count in this way?

Posted on 2009-02-08
3
Medium Priority
?
328 Views
Last Modified: 2013-12-16
Hi ,
i am storing an arraylist in application state and when i try to get the count i get the an error any idea?

Below is my code.
        ArrayList myList = (ArrayList)Application["V"];
        if (myList.Count == 0)
        { Response.Write("something"); }

Error : Object reference not set to an instance of an object.
0
Comment
Question by:Raul77
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
Allamz earned 1000 total points
ID: 23585452
Raul,

please try below
ArrayList myList = new ArrayList();
myList = (ArrayList)Application["V"];
if(myList != null)
{
        if (myList.Count == 0)
        { Response.Write("something"); }
}
else
Response.Write("ArrayList Is Empty"); 

Open in new window

0
 

Author Closing Comment

by:Raul77
ID: 31544310
Thanks worked :)
0
 
LVL 6

Expert Comment

by:Allamz
ID: 23585491
Raul,

You are more than welcome, Please don't hesitate to contact me if you require further assistance.

Best Regards,

Mohamed Allam
Senior Software Engineer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question