IntroductionC#4.0 has introduce a new feature call Tuple.Definition
In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an (ordered) n-tuple is a sequence (or ordered list) of n elements, where n is a positive integer. There is also one 0-tuple, an empty sequence. (From Wikipedia) Purpose: Some time we need to return more than one value from a method or function.Using the codeLet us perform a simple experiment for the basic arithmetic operations for the concept to understand. Let us first write our Calculate Function ///
/// Calculate
private void Calculate(out int add, out int sub,out int mul,out int div)
{
int num1 = 5;
int num2 = 4;
add = num1 + num2;
sub = num1 - num2;
mul = num1 * num2;
div = num1 / num2;
}Older approach (Till dotnet 3.5)Approach 1: Using OUT parameterRead more: Codeproject
In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an (ordered) n-tuple is a sequence (or ordered list) of n elements, where n is a positive integer. There is also one 0-tuple, an empty sequence. (From Wikipedia) Purpose: Some time we need to return more than one value from a method or function.Using the codeLet us perform a simple experiment for the basic arithmetic operations for the concept to understand. Let us first write our Calculate Function ///
/// Calculate
private void Calculate(out int add, out int sub,out int mul,out int div)
{
int num1 = 5;
int num2 = 4;
add = num1 + num2;
sub = num1 - num2;
mul = num1 * num2;
div = num1 / num2;
}Older approach (Till dotnet 3.5)Approach 1: Using OUT parameterRead more: Codeproject
0 comments:
Post a Comment