I am really confused about NEW keyword use in C# and MVC -


what know new follows 1) when creating object in class ,array list etc example:

public class employee { public int id {get;set;} public string name{get;set;} }   } public static main(){ var emp n = new employee;  } 

2) modifier

public class basec {     public static int x = 55;     public static int y = 22; }  public class derivedc : basec {     // hide field 'x'.      new public static int x = 100;      static void main()     {         // display new value of x:         console.writeline(x);          // display hidden value of x:         console.writeline(basec.x);          // display unhidden member y:         console.writeline(y);     } } /* output: 100 55 22 */ 

but going show scenario feel difficult how new key word implementing here . think first new word used create manager object use of second new or (new userstore<applicationuser>. ccould explain please.

var manager = new applicationusermanager(new userstore<applicationuser>(context.get<applicationdbcontext>())); 

how new keyword used invoke statement below:

app.createperowincontext<applicationusermanager>(applicationusermanager.create); 

the actual question how

applicationusermanager(new userstore<applicationuser>(context.get<applicationdbcontext>())); 

could interpreted, right?

pretty straightforward:

you create new userstore of specific type t t application user

so

userstore<applicationuser> mystore = new userstore<applicationuser>(); 

this mentaioned 1), nothing special except generic "of t". in specific case use overload use constructor takes contecxt object

userstore<applicationuser> mystore = new userstore<applicationuser>(context.get<applicationdbcontext>()); 

after use newly created object in application manager (altough think example missing something)

applicationusermanager(mystore); 

the initial code above simple 1 liner because wouldn`t need mystore object.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -