// creating a new container IContainer container = new Container(); // adding components to the container container.Add(new Component1()); container.Add(new Component2()); // retrieving a component from the container var component1 = container.Get();
// creating a new Unity container IUnityContainer container = new UnityContainer(); // registering types with the container container.RegisterTypeIn this example, we are using the Unity library to create a new container and register two types with it. We then resolve a dependency using the `Resolve` method. Package library: Microsoft.Extensions.DependencyInjection.(); container.RegisterType (); // resolving dependencies from the container var service = container.Resolve ();