C#C
C#3y ago
Relevant

❔ ✅ Register instance of List as singleton

This feels like a dumb question, but I'm trying to keep a singleton instance of a List that can be added to by different areas of the application. This doesn't seem to work:

builder.Services.AddSingleton<List<MyThing>>();


or

List<MyThing> myThings = new();
builder.Services.AddSingleton(myThings);
Was this page helpful?