0

If I use a IoC container and the strong implementation is instantiated at runtime, dunamically, which among the below initialization is a best practice?

var obj=FooIocContainer.Resolve<IInterface>();

or

IInterface obj=FooIoCContainer.Resolve<IInterface>();

Which one is better and why? Just being curious :)

Ananthan Unni
  • 1,304
  • 9
  • 23

1 Answers1

1

It depends on the scope of the object you create. If its local then var will do. If you need to expose it using public properties, use specific Interface types.

Carbine
  • 7,849
  • 4
  • 30
  • 54