© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago•
3 replies
Vortac

IDisposable Constructor Injection

If I new up a class to inject via constructor injection which has an IDisposable object, does the class receiving the IDisposable parameter need to implement IDisposable?

eg:
 using var soundEngine = new MiniAudioEngine(44100, Capability.Playback);
var player = new SoundEngine(soundEngine);
 using var soundEngine = new MiniAudioEngine(44100, Capability.Playback);
var player = new SoundEngine(soundEngine);

Does player need to be
using var player
using var player
?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

IDisposable ownership semantics
C#CC# / help
15mo ago
❔ Service provider, IDisposable
C#CC# / help
3y ago
✅ Implementing IDisposable properly
C#CC# / help
3y ago
IDisposable and using keyword?
C#CC# / help
2y ago