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

  • Home
  • SEARCH
  • 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 705187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:01:31+00:00 2026-05-14T04:01:31+00:00

In my application I have a class which has properties of user-defined types like

  • 0

In my application I have a class which has properties of user-defined types like this:

class MyType
{
    public A MyProperty
    {
        get;
        set;
    }
}
class A
{
    .....some methods and proeprties
}

for some operations that I need to perform from my main program, I have created a List of A and add in to it MyProperty whenever creating object of MyType

List<A> myList = new List<A>();

MyType m1 = new MyType();
myList.Add(m1.MyProperty);

MyType m2 = new MyType();
myList.Add(m2.MyProperty);

......more instances

and pass it to my main program and there I perform different operation on these properties which reflects in there instances also. Is there any way by which I could get the object instance for any particular MyProperty from that property in the list.

  • 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-14T04:01:32+00:00Added an answer on May 14, 2026 at 4:01 am

    I suspect you mean you’re creating a List<A> and you want to be able to find out from an instance of A which instance of MyType “owns” it. There’s no way of doing that without putting the information in A (or having a comprehensive list of instances of MyType and checking them). After all, two instances of MyType could have the same A:

    MyType first = new MyType();
    MyType second = new MyType();
    A a = new A();
    first.MyProperty = a;
    second.MyProperty = a;
    

    Which MyType is a logically associated with? Both or neither, really…

    The cleanest approach is to make A know about which MyType it’s associated with explicitly – then you can decide what should happen if you try to have one instance of A associated with two instances of MyType (should it throw an exception? Keep both as a list? Keep the newer?) You probably want to make the MyType.MyProperty update the value that’s passed in, to keep the association in sync.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called User which has 2 properties : login/password. I am
I have a class Application that my global.asax inherits from. The class has this
I have a .NET 3.5 web application for which I have implemented a class
I have this code inside a class that is used by an application and
I have a Java application with a custom defined Look and Feel in which
I have a class that has purely static Methods and properties. I am calling
I have a simple class which has a static constructor and a instance constructor.
In my application I have a Customer class and an Address class. The Customer
Suppose I have a class 'Application'. In order to be initialised it takes certain
I have a custom class loader so that a desktop application can dynamically start

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.