Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions How to create array with non default value in C



C# Array initialization - with non-default value

View(s): 28617

How to create array with non-default value in C#?

Answer 1)
 
Using Enumerable.Repeat

Example:

bool[] boolArray = Enumerable.Repeat(true, 10).ToArray(); // creates bool array of size 10 with default value "true"

int[] intArray = Enumerable.Repeat(100, 20).ToArray(); // creates int array of size 20 with default value "100"

string[] strArray = Enumerable.Repeat("Hello", 5).ToArray();// creates string array of size 5 with default value "Hello"

  Asked in:  Mahindra Satyam   Expertise Level:  Experienced
  Last updated on Sunday, 10 June 2012
4/5 stars (29 vote(s))

Register Login Ask Us Write to Us Help