What is the C# equivalent of Python slice operations?
my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] result1 = my_list[2:4] result2 = my_list[1:] result3 = my_list[:3] result4 = my_list[:3] + my_list[4:]
Some of it is covered here, but it is ugly and doesn't address all the uses of slicing to the point of it not obviously answering the question.
The C program is the human-readable form, while the executable that comes out of the compiler is the machine-readable and executable form. What this means is that to write and run a C program, you must have access to a C compiler.
Readable code is simply code that clearly communicates its intent to the reader. Most likely, the code we write will be read by other developers, who will either want to understand or modify the way our code works. They may need to test the code, fix a problem, or add a new feature.
To overcome such issues, Microsoft developers recently announced to use the Rust programming language instead of C and C++ to write and code the components of Windows.
The closest is really LINQ .Skip()
and .Take()
Example:
var result1 = myList.Skip(2).Take(2); var result2 = myList.Skip(1); var result3 = myList.Take(3); var result4 = myList.Take(3).Concat(myList.Skip(4));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With