I analyzed code of malware written in C# and came across something unclear to me. The LINQ OrderBy
method was applied on a char
array. However, I was suprised about the lambda expression inside, which was similar to the one below.
var charArray = "abcdefghijk".ToCharArray();
string generatedString = new string(charArray
.OrderBy(s => (random.Next(2) % 2) == 0)
.ToArray());
I wonder how it works if the expression value is bool
. It is also puzzling to me that if I put simple true
or false
values there instead, I always get the same string
of "abcdefghijk" characters. Why is it always mixed up with this expression?