Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:47+00:00 2026-05-23T00:56:47+00:00

I made a static function that returns me an ArrayList of objects: allThread =(ArrayList)

  • 0

I made a static function that returns me an ArrayList of objects:

 allThread =(ArrayList) AllQuestionsPresented.GetAllThreads();

Now the objects have properties that i want to get out. But I noticed that i cant type allThreads.Name…or
allThreads[“Name”] , or allThreads[1], it wont give me the object itself. Cause intellisense doesnt recognize it..

Here is what I am trying to do..:

That function is in one class:

    public static ICollection GetAllThreads()
{
    ArrayList allThreads = new ArrayList();
    string findUserID = "SELECT UserID FROM Users";
    string myConnectionString = AllQuestionsPresented.connectionString;

    using (SqlConnection myConnection = new SqlConnection(myConnectionString))
    {
        SqlCommand sqlCommand = new SqlCommand(findUserID, myConnection);
        SqlDataReader reader = sqlCommand.ExecuteReader();
        while (reader.Read())
        {
            AllQuestionsPresented allQ = new AllQuestionsPresented((Guid)reader["UserID"]);
            allThreads.Add(allQ);
        }
    }
    return allThreads;
}

That is some code from another function in another class:

    forumsPages = new Dictionary<int, List<DisplayAllQuestionsTable>>();
    allThread =(ArrayList) AllQuestionsPresented.GetAllThreads();//I want to convert the ICollection


    for (int i = 0; i < 20; i++)
    {
        threads.Add(new DisplayAllQuestionsTable(allThread[i].//And use it here. I want an object to be returned..same object that was stored in the ArrayList in the static function

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:56:48+00:00Added an answer on May 23, 2026 at 12:56 am

    USE A List:

     public static List<AllQuestionsPresented> GetAllThreads()
    {
        List<AllQuestionsPresented> allThreads = new List<AllQuestionsPresented>();
        string findUserID = "SELECT UserID FROM Users";
        string myConnectionString = AllQuestionsPresented.connectionString;
    
    using (SqlConnection myConnection = new SqlConnection(myConnectionString))
        {
            SqlCommand sqlCommand = new SqlCommand(findUserID, myConnection);
            SqlDataReader reader = sqlCommand.ExecuteReader();
            while (reader.Read())
            {
                AllQuestionsPresented allQ = new AllQuestionsPresented((Guid)reader["UserID"]);
                allThreads.Add(allQ);
            }
        }
        return allThreads;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a java swing GUI. Now I want to display a static
Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort()
i have made a function which works just fine with 32-bit dates (acceptable with
Hey I'm trying to write a function that calls a static function based upon
I have a database class that I made that uses PDO to connect to
I have made a console app that adds and subtracts fractions, I have added
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a code that translate strings to match each word from the array
I have a custom class that, when called, will redirect to a page and
Today I saw a JavaScript syntax (when invoking a function) that is unfamiliar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.