I have list1 that is constantly changing based on user input, I wanted to store a “screenshot” of the contents of list1 using a list of lists each time something new is added to list1.

my program adds a new list correctly however since im just adding from list1 each time the values of every list in the list of lists gets updated to the most recent version of list1.
Is there anyway to “freeze” the values of a list once it has been added or perhaps a better way to go about taking “screenshots” of lists entirely.
edit: I did this
right before I added to the list of lists. I am not fully sure on the mechanics but I’m pretty sure it removes the previous temp reference every time since its new so the nested lists dont get updated.
Use an immutable list.
do you know of any resources that could show how to create an immuatble list of lists, I cant seem to find anything thats very clear
How are you creating new lists from list1?
I had a list of lists and was adding list1 to it each time list1 was changed, however since its by reference the older lists would get updated with the list1 changes. I just realized that I had to create a new temp with list1 data right before I add (so it removes the reference to temp each time, not sure if thats the right explanation but I think it conveys the message)
C# devs
null reference exceptions

source