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 8166067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:44:05+00:00 2026-06-06T19:44:05+00:00

I am writing a sort of image processing program that allows the user to

  • 0

I am writing a sort of image processing program that allows the user to open as many images as they want. Everytime the user opens an image the program has to create an object for it, which is defined by some class MyClass.
Obviously, when I create this object within the method of “opening the image” (e.g. clicking a menu button File -> Open…) the object is only known within this method and will be useless to other methods of the UI. I could create an array within the UI class and then just assign the object to MyClass[i] and keep counting up i, but that is not an option as I can’t know how many images the user wants to open. Also the user has to be able to close images again, which means that this index i will be useless.

Is there a way to somehow have a collection of objects to which I can add and remove objects dynamically? The objects have to be able to identify themselves within this collection by lets say the filename.

I am quite new to C# so please try to explain everything as detailed as possible.

  • 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-06-06T19:44:06+00:00Added an answer on June 6, 2026 at 7:44 pm

    What you need is a dynamic data structure like a List.

    You can use either the generic (i.e. List) or the non-generic (i.e. List) version. With a List your are able to dynamically add or insert items, determine their indices and to remove items as you like.

    The size of the list grows/shrinks dynamically as you are using the lists operations.

    Suppose your images are represented as objects of type Image then you can use a List like that:

    // instantiation of an empty list
    List<Image> list = new List<Image>();
    
    // create ten images and add them to the list (append at the end of the list at each iteration)
    for (int i = 0; i <= 9; i++) {
    
        Image img = new Image();
        list.Add(img);
    }
    
    // remove every second image from the list starting at the beginning
    for (int i = 0; i <= 9; i += 2) {
    
        list.RemoveAt(i);
    }
    
    // insert a new image at the first position in the list
    Image img1 = new Image();
    list.Insert(0, img1);
    
    // insert a new image at the first position in the list
    IMage img2 = new Image();
    list.Insert(0, img2);
    

    Alternative approach by using Dictionaries:

    Dictionary<string, Image> dict = new Dictionary<string, Image>();
    
    for (int i = 0; i <= 9; i++) {
    
        Image img = new Image();
    
        // suppose img.Name is an unique identifier then it is used as the images keys
        // in this dictionary. You create a direct unique mapping between the images name
        // and the image itself.
        dict.Add(img.Name, img);
    }
    
    // that's how you would use the unique image identifier to refer to an image
    Image img1 = dict["Image1"];
    Image img2 = dict["Image2"];
    Image img3 = dict["Image3"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an android application that scans an image and creates a sort of
I am writing an Objective-C program that deals with low level image memory. I
Scala programmer should have known that this sort of writing : class Person{ var
Writing a client application that sends images to a server via a webservice. As
I'm writing some sort of backup tool that has to copy all the files
I've been writing an image processing algorithm now, and at some point I needed
So, I am writing some sort of a statistics program (actually I am redesigning
I'm writing a plug-in interface for an OSX image processing application. It's designed around
I'm writing an application, in which the user needs to solve a recaptcha image
I'm writing an android app and in it I want to have a sort

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.