C
C#2y 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>>();
builder.Services.AddSingleton<List<MyThing>>();
or
List<MyThing> myThings = new();
builder.Services.AddSingleton(myThings);
List<MyThing> myThings = new();
builder.Services.AddSingleton(myThings);
2 Replies
Relevant
RelevantOP2y ago
Nevermind, that works fine, the issue was somewhere else ✅ !close
Accord
Accord2y ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server