Passing an array to a method?
-
Hi, I have a question related to passing an array to a method. In C++, if I have an array Arr[] with 20 elements, and I want to pass the array to a method, but starts from the 10th element, then I would do the following: AMethod(Arr + 10); If I want to do the same thing in C#, what would be the proper way? Thanks a lot.
-
Hi, I have a question related to passing an array to a method. In C++, if I have an array Arr[] with 20 elements, and I want to pass the array to a method, but starts from the 10th element, then I would do the following: AMethod(Arr + 10); If I want to do the same thing in C#, what would be the proper way? Thanks a lot.
Pass the offset and length. It is always a good practice.
A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
-
Hi, I have a question related to passing an array to a method. In C++, if I have an array Arr[] with 20 elements, and I want to pass the array to a method, but starts from the 10th element, then I would do the following: AMethod(Arr + 10); If I want to do the same thing in C#, what would be the proper way? Thanks a lot.
Use the System.ArraySegment generic class.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango