Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

replace an object from the list

$
0
0

Hi All,

I am using VS2010 for my application. Now I have a scenario. asmple code {excuse syntax here.. . }

I have a User Defined Object ObjSample. I have created a list for that.

List<ObjSample> ObjList = new List<ObjSample>{ };

===Now I have populated this object list with some objects. Further . . 

ObjSample A = new ObjSample();

A.ID = 555;

A.Name = "TestName";

=== Now what Ihave to do it from the collection ObjList if any object is having .ID = 10 then I have to replace that object with A.

I know one way is to loop the Object List and check 

If Obj.ID = 10 then

Obj = A;

Now I want to know if there is any way to accomplish this by using Lambda or Linq or any other way.

I guess I am clear with the question. Please let me know if I am not clear with my question.
Please let me know

Regards,
Girish Nehte 


Viewing all articles
Browse latest Browse all 23244

Trending Articles