Author Topic: What does this line mean in C#?  (Read 311 times)

carine

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
  • Welcome to solution.mypressonline
What does this line mean in C#?
« on: February 19, 2014, 09:07:39 AM »
I am just new to C# and trying to debug through a code during my project. At so many places i can see

ServiceContainer.Resolve<MyClass>

I just want to know if it will return the same object every time or it will create a new object of MyClass every time its get called ?.

victor@007

  • Administrator
  • Newbie
  • *****
  • Posts: 8
  • Karma: +0/-0
Re: What does this line mean in C#?
« Reply #1 on: February 19, 2014, 09:17:52 AM »
What it will return depends on the underlying IoC (inversion of control) configuration. You can configure (most of) IoC containers to return, either the same instance, one instance per Resolve, one instance per thread, one instance per http request, etc.

There are also several ways of specifying how MyClass maps to AnotherImplementationOfMyClass (usually MyClass is an interface).

Usually you'll find the scope of the mapping together with the mapping configuration. Here you can find an example with Ninject

leo holly

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
  • Welcome to solution.mypressonline
Re: What does this line mean in C#?
« Reply #2 on: February 21, 2014, 05:34:26 AM »
hello! please i want to speak english.. can you help me. thinks

victor@007

  • Administrator
  • Newbie
  • *****
  • Posts: 8
  • Karma: +0/-0
Re: What does this line mean in C#?
« Reply #3 on: March 11, 2014, 07:51:59 AM »
hello leo holly,
 Please at this board we don't discuss english language issue. PLease go on the Education category under others and paste your question. thanks for your understanding.....
URL:: http://forum.superadsolution.com/index.php?board=57.0

papi

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
  • Welcome to Forum.superadsolution
Re: What does this line mean in C#?
« Reply #4 on: July 19, 2014, 05:13:05 AM »
sue it will return!