c# empty array

99

c# check if array is empty -

if(array == null || array.Length == 0)

c# initialize empty array -

datatype[] arr = new datatype[]{};
or
datatype[] arr = new datatype[0];
or
datatype[] array = {}
or
var a = Array.Empty<datatype>();

c# empty array -

object[] emptyArray = new object[0]; 

c# empty array -

var listOfStrings = new List<string>();

// do stuff...

string[] arrayOfStrings = listOfStrings.ToArray();

Comments

Submit
0 Comments