469,362 Members | 2,498 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

Update current Item in LIST<T>

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

Thanks
Dec 28 '05 #1
4 27701
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.