WebSep 15, 2024 · You can pass an initialized single-dimensional array to a method. For example, the following statement sends an array to a print method. C# int[] theArray = { 1, 3, 5, 7, 9 }; PrintArray (theArray); The following code shows a partial implementation of the print method. C# void PrintArray(int[] arr) { // Method code. } WebFeb 20, 2012 · An IntPtr (IntegerArrayReceiver ) is used to receive the pointer to the integer array created and returned by the ReturnIntegerArray () API. After the ReturnIntegerArray () is called, IntegerArrayReceiver will contain the address of the array.
C# IEnumerable Examples - Dot Net Perls
WebAug 25, 2024 · The LINQ returns IOrderedIEnumerable, which is converted to Array using ToArray () method. CSHARP using System; using System.Linq; class GFG { public static void Main () { int[] arr = new int[] {1, 9, 6, 7, 5, 9}; arr = arr.OrderByDescending (c => c).ToArray (); foreach(int value in arr) { Console.Write (value + " "); } } } Output: 9 9 7 6 5 1 how often to water potatoes in containers
Array Class (System) Microsoft Learn
WebIf you want the method to return a value, you can use a primitive data type (such as int or double) instead of void, and use the return keyword inside the method: Example Get your own C# Server static int MyMethod(int x) { return 5 + x; } static void Main(string[] args) { Console.WriteLine(MyMethod(3)); } Try it Yourself » WebDec 3, 2024 · #include /** * Function to return an array using pointers. * @return Pointer to array */ int * getArray() { int num[] = {1, 2, 3, 4, 5}; int i; printf("Array inside function: "); for (i = 0; i < 5; ++i) { printf("%d\n", num[i]); } return num; } int main() { int i; int * num; num = getArray(); printf("Array outside function: \n"); for (i = 0; i < … WebAug 16, 2006 · TRIs it possible to return an array from a function? if so, how would I TRgo about doing so? AFAIK you can do it via return value or via out param. I'm not mentioning ref here. int[] array; //returns array with 2 elements public int[] ReturnArray() {return new int[] {1,2};} public void ReturnArray(out int[] array) {array = new int[] {1,2};}-- how often to water potted jasmine