Click here to Skip to main content
13,291,748 members (53,085 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 5 Oct 2009

Tuple in C# 4.0

, 5 Oct 2009
Rate this:
Please Sign up or sign in to vote.
C# 4.0 includes a new feature called Tuple.

C# 4.0 includes a new feature called Tuple. In mathematics, tuple is an ordered list of specific number of values called the components of the tuple. For example, a 3-tuple name may be used as: (First-Name, Middle-Name, Last-Name).

Let's take a look at the following example:

public Tuple<int, int> GetDivAndRemainder(int i, int j) 
    Tuple.Create(i/j, i%j); 
public void CallMethod() 
    var tuple = GetDivAndRemainder(10,3); 
    Console.WriteLine("{0} and {1}", tuple.item1, tuple.item2); 

In the above example, the method can return a tuple which has two integer values. So using tuple, we can return multiple values. So this will help lazy programmers to write less code but do more. One great use of tuple might be returning multiple values from a method.

To get more information on Tuple, visit the following links:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Architect ImpleVista Aps
Denmark Denmark
Sohel has more than six years of experience in professional software development with extensive involvement in Web based Object-Oriented, Multi-Tiered application design and development. He's Familiar with Test Driven Development (TDD) and refactoring techniques as well as having expertise in architecturing large enterprise applications. He has Experience in working with Content Management System and Portal Management System tools like SharePoint, DotNetNuke, Ektron.

Over last few years, he’s involved in development with projects on Microsoft SharePoint and received Microsoft MVP for SharePoint Server Development in the year 2011 and 2012. Currently he's working in a software company located Copenhagen,Denmark on a project integrating SharePoint and SAP. You can read his popular blog at:

You may also be interested in...

Comments and Discussions

GeneralTuples behaviour! Pin
VizualNeel19-Jan-10 18:20
memberVizualNeel19-Jan-10 18:20 
GeneralRe: Tuples behaviour! Pin
Sohel_Rana19-Jan-10 19:29
memberSohel_Rana19-Jan-10 19:29 
GeneralRe: Tuples behaviour! Pin
VizualNeel19-Jan-10 20:23
memberVizualNeel19-Jan-10 20:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 5 Oct 2009
Article Copyright 2009 by Sohel_Rana
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid