January 2012
Intermediate to advanced
396 pages
8h 16m
English
Since Tuple is a new inclusion in the .NET 4.0 Framework and can prove to be handy in a lot of situations, I thought it would be a great place to showcase an unusual use of this beautiful data representation technique.
Let's say we have situations involving four integers. This is generally represented using nested if-else blocks, as shown in the following code. However, we can use a Tuple to refactor this code, as we shall see in a while:
static int x = 11; static int y = 9; static int z = 20; static int w = 30;
Main() method:if (x > 9) { if (y > x) { if (z > y) { if (w > 10) { Console.WriteLine(" y > x and z > y and w > 10 "); ...Read now
Unlock full access