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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:22:17+00:00 2026-06-17T20:22:17+00:00

I have a list<Myobj> source which contains some Myobj instances, if I assign it

  • 0

I have a list<Myobj> source which contains some Myobj instances, if I assign it to an empty list<MyObj> target what exactly happens in terms of contents?

Are Myobj instances duplicated in target via shallow copy? is the copy contructor called? or are they not duplicated at all?

  • 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-17T20:22:19+00:00Added an answer on June 17, 2026 at 8:22 pm

    All the objects in the first list are copied into the second list. It is better not to think about “shallow” and “deep” copying here. The elements are copied, and the “depth” of the copy depends on what the class’ copy constructor or assignment operator do. If your type T were a plain pointer, then the pointers would get copied, but not what they point to. There is no special magic going on.

    Note that there are some subtleties which depend on what the source, or RHS of the assignment is (thanks to @mooingduck for reminding me of this). In C++11, there are situations in which the contents of the RHS could be moved into the LHS, in which case there is no copying at all.

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

Sidebar

Related Questions

I have List where myObj has it own list of objects called example mySubObj.
I have a List<MyObj> with the class MyObj : IComparable . I wrote the
I have List I want to sort Desc by Priority, which is int and
I have List<string> strs; double[] values; where the values array contains the value of
I have a List < MyObj > I have also overriden Equals(Object) in class
I have a generic list: IList<T> myobj = new List<T>(); how to check if
I have List = [0, 1, 2, 3] and I want to assign all
I have a list of objects in this format : class myObj { private
I have: Dim aList As List(Of myObj.Answers) = myObj.GetResults(someID) This returns: aList.AnswerID | aList.AnswerCount
In C#, if I have a List<MyObj> where MyObj is a custom class with

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.