472,129 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 software developers and data experts.

Update current Item in LIST<T>

How do I update a current item in the LIST<T>?

Thanks
Dec 28 '05 #1
4 27803
Viviek,

If T is a value type, then you have to store the value type to a temp
variable and then set it back when you are done making changes to it. If it
is a reference type, you can use the indexer and just access the item
directly from that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
How do I update a current item in the LIST<T>?

Thanks

Dec 28 '05 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> a écrit
dans le message de news: uq**************@TK2MSFTNGP10.phx.gbl...

| Viviek,
|
| If T is a value type, then you have to store the value type to a temp
| variable and then set it back when you are done making changes to it. If
it
| is a reference type, you can use the indexer and just access the item
| directly from that.

Am I suffering from déjà vu or haven't several people already answered this
poster's question in several different threads ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 28 '05 #3
I believe so. Sometimes, it's just so hard to remember...
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> a écrit
dans le message de news: uq**************@TK2MSFTNGP10.phx.gbl...

| Viviek,
|
| If T is a value type, then you have to store the value type to a temp
| variable and then set it back when you are done making changes to it.
If
it
| is a reference type, you can use the indexer and just access the item
| directly from that.

Am I suffering from déjà vu or haven't several people already answered
this
poster's question in several different threads ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Dec 28 '05 #4
Do this :

// value type sample
//
List<int> li = new List<int>();
li.Add(12345);
li[0] = 54321; // It works

// reference type sample
//
List<object> lo = new List<object>();
lo.Add(null);
lo[0] = new List<int>();

"Nicholas Paldino [.NET/C# MVP]" wrote:
Viviek,

If T is a value type, then you have to store the value type to a temp
variable and then set it back when you are done making changes to it. If it
is a reference type, you can use the indexer and just access the item
directly from that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vivek" <vi****@xtra.co.nz> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
How do I update a current item in the LIST<T>?

Thanks


Dec 29 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by bob_jeffcoat | last post: by
9 posts views Thread by Stephan Steiner | last post: by
1 post views Thread by swiftalpha | last post: by
6 posts views Thread by A.Rocha | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.