This sample program will help you to pass arrays and returns arrays from a function in C#. use the below program to develop complex functions to return and accept values.
Output:
source Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] intArray = { 1 , 2, 3 , 4, 5 };
Program obj = new Program();
int[] ResultArray = obj.PassArray(intArray);
foreach (int ArrayItem in ResultArray)
{
Console.Write(ArrayItem + " ");
}
Console.ReadLine();
}
private int[] PassArray(int[] tempArray)
{
return tempArray;
}
}
}
No comments:
Post a Comment