In C# 8.0, why can I use range on single dimensional arrays:
var oneDim = new int[5];
var oneDimSlice = oneDim[2..4];
But can not use it on multi dimensional arrays ?
var twoDim = new int[5, 5];
var twoDimSlice = twoDim[2..4, 2..4];
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/ranges-indexes
Array has more nuanced behavior. Single dimension arrays support both indices and ranges. Multi-dimensional arrays don't. The indexer for a multi-dimensional array has multiple parameters, not a single parameter. Jagged arrays, also referred to as an array of arrays, support both ranges and indexers.
so the answer is no, but it is possible to do it with jagged arrays if you are interested.
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