c# - Adding values to member fields of object in List<T> at same index -


i have collection of type object called mhp. mhp has multiple member fields(name, ac, par_id, etc). create list;

private list<mhp> mhplist = new list<mhp>(); public list<mhp> mhplist { { return mhplist; } set { mhplist = value; } } 

and populate portion of fields values in loop creating new object:

mhplist.add(new mhp {  mhp_name = something,  mhp_ac = number });  

now want populate remaining field value , i’m doing creating new object, places value in new index of collection;

mhplist[0] mhp_name = ‘something’, mhp_ac = ‘#’, mhp_parid = null.

mhplist[1] mhp_name = null, mhp_ac = null, mhp_parid = ‘something’

i’ve tried creating new list , adding new object list using following add new list mhplist:

mhplist.addrange(newlist)

as wellas , mhp.insertrange, each time add new index of object in collection. how add values unpopulated fields within same index of collection?

just access item using it's index:

mhplist = new list<mhp>();  mhplist.add(new mhp {  mhp_name = something,  mhp_ac = number });  mhplist[0].mhp_parid= "something"; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -