We are excited to announce that the ASP.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

## 5 replies

Last post Jun 28, 2015 07:21 PM by PaulLinton

• sudip_inn

Contributor

2231 Points

3706 Posts

### What is the difference between Tuple and List

people said tuple is immutable whose value can not be change after adding in it but list is mutable.

but other difference is not clear as follows

a) Lists are intended to be homogeneous sequences, while tuples are heterogeneous data structures

what they try to say homogeneous and heterogeneous. discuss this point with example.

b) Lists are for looping, tuples are for structures

c) Lists are for variable length, tuples are for fixed length.

please discuss all the points. thanks

• gerrylowry

Star

14297 Points

5797 Posts

### Re: What is the difference between Tuple and List

@sudip_inn   again, i ask "Do you ever use Google or MSDN to understand the many questions that you ask here"?

The best way to understand is to use resources like Google and MSDN!

Study https://msdn.microsoft.com/en-us/library/vstudio/hh297117(v=vs.100).aspx "Step 1: Working with Tuples

sudip_inn, have you considered taking a course or hiring a c# tutor?

http://stackoverflow.com/questions/2745426/practical-example-where-tuple-can-be-used-in-net-4-0

For more, search via Google:         msdn c# tuple when to use

B-)  Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it
• sudip_inn

Contributor

2231 Points

3706 Posts

### Re: What is the difference between Tuple and List

a) Lists are intended to be homogeneous sequences, while tuples are heterogeneous data structures. what point a try to say....need some example.

what they try to say homogeneous and heterogeneous. discuss this point with example.

b) Lists are for looping, tuples are for structures.                  need some example

c) Lists are for variable length, tuples are for fixed length.      need some example

the away u answer sound very rude as if i am forcing you to answer.

• gerrylowry

Star

14297 Points

5797 Posts

### Re: What is the difference between Tuple and List

@sudip_inn  you are not forcing me to answer.

Did you ever take time to thoughtfully read "Clarity is important, both in question and in answer"?

sudip_inn, a well known saying, veganized, is "Give a person a potato, you feed him/her for a day; teach the person how to grow potatoes, you feed him/her for a lifetime".

i was born in 1947, so it's likely that i will not be around for too many more decades.

MORE  INFORMATION

i used to be a community college teacher ... your questions sound to my ear much like the type of questions i'd ask my students.

msdn c# tuple example      http://lmgtfy.com/?q=msdn+c%23+tuple+example

Excellent article:  http://www.dotnetperls.com/tuple

what is a tuple c#        http://lmgtfy.com/?q=what+is+a+tuple+c%23

LISTS ARE LISTS AND TUPLES ARE TUPLES!

via Google:      can i have a c# list of tuples?

sudip_inn ... if you really want to get the best help from your peers here at forums.asp.net, or any c# forum for that matter, first use resources like Google and MSDN, next try the code you find there in environments like Visual Studio and LINQPad ... then, when you've made an honest effort but you're stuck, ask very specific questions in the forum(s) of your choice.

N.B.:  i have been programming c# almost exclusively since 2009 and i've never needed the use a tuple.

FWIW

B-)  Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it
• sudip_inn

Contributor

2231 Points

3706 Posts

### Re: What is the difference between Tuple and List

i know what is the meaning of homogeneous & heterogeneous.

i try to understand this line "Lists are intended to be homogeneous sequences, while tuples are heterogeneous data structures. what point a try to say....need some example." with example like why tuples are considered as heterogeneous data structures. for this i need a sample example code to understand why tuples are considered as heterogeneous data structures

• PaulLinton

Member

141 Points

55 Posts

### Re: What is the difference between Tuple and List

Tuples and Lists have very, very little to do with each other.  You question is like asking the difference between an int and an array.

You can think of a Tuple as a 'lazy' class in that you do not name all the properties (the names are pre-defined) but only need to specify their types.  There are Tuple Factory methods which make the creation even easier by using generics so that you do not even have to directly specify the data types.

A List is .... well ... a list of things.  They could be anything but each element is of the same type and the list will have from zero to many of them.

A Tuple is a 'thing'

A List is a collection of 'things'.

With a Tuple the typical actions are creating and accessing members -

myTuple.Item1 += 4;

var x = new Tuple("Mary", 27)

that sort of thing

A List is all about adding items to it and stepping through the items to process them.