Create Array with default value - CSharp System

CSharp examples for System:Array Create

Description

Create Array with default value

Demo Code


using Microsoft.Research.DynamicDataDisplay.Charts;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*  w w w .ja  v  a  2s .  c om*/

public class Main{
        internal static T[] CreateArray<T>(int length, T defaultValue)
      {
         T[] res = new T[length];
         for (int i = 0; i < res.Length; i++)
         {
            res[i] = defaultValue;
         }
         return res;
      }
}

Related Tutorials