C# 7 introduced tuples which enables swapping two variables without a temporary one:
int a = 10;
int b = 2;
(a, b) = (b, a);
This assigns b
to a
and a
to b
.
More Related Contents:
- I am interested in a more optimized solution for sum of all fizzbuzz numbers in a given range
- Different combinations of an array (C#)
- Algorithm to detect overlapping periods [duplicate]
- What is the best way to find all combinations of items in an array?
- All Possible Combinations of a list of Values
- Quick and Simple Hash Code Combinations
- Remove text in-between delimiters in a string (using a regex?)
- Algorithm to find which numbers from a list of size n sum to another number
- How to “zip” or “rotate” a variable number of lists?
- C# hashcode for array of ints
- Detect if geolocation is in complex polygon or not
- How to create a trie in c# [closed]
- Efficient Cartesian Product algorithm
- Finding all combinations of well-formed brackets
- Best hashing algorithm in terms of hash collisions and performance for strings
- LINQ to find series of consecutive numbers
- Reversible shuffle algorithm using a key
- DirectoryInfo.EnumerateFiles(…) causes UnauthorizedAccessException (and other exceptions)
- C#: Seeking PNG Compression algorithm/library [closed]
- Memory-constrained external sorting of strings, with duplicates combined&counted, on a critical server (billions of filenames)
- Find if point lies on line segment
- What’s the quickest way to compute log2 of an integer in C#?
- Flood Fill Algorithms
- Creating a power set of a Sequence
- All cases covered Bresenham’s line-algorithm [closed]
- Sorting a linked list
- How to use LINQ to find all combinations of n items from a set of numbers?
- Detect a specific frequency/tone from raw wave-data
- C#: How to make Sieve of Atkin incremental
- How to parse a boolean expression and load it into a class?