Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of C#
  • Discussion

  • Study Guides

  • Table of Contents

Bookmark and Share
Lecture Comments (1)

0 answers

Post by Thuy Nguyen on September 11, 2014

Hi Professor Snape, I also thought that you had to initialize an array before you use it, but I tested out a double[,] array Without initializing it via a for loop. Then I printed its value and saw that the default value is 0.

I also made an array of enum values, without initializing it.  Again, the array is automatically filled with a default value (the first value in the enum).

So I see that we don't need to initialize an array via a for loop to start using it because the array is automatically filled with a default value (based on the type of array).

Arrays, Stacks, Queues & Dictionaries

  • Arrays hold values of the same data type
  • Stacks are First In, Last Out (FILO)
  • Queues are First In, First Out (FIFO)
  • Dictionaries are used to hold a “keyed” set of values
  • The lower bound of arrays is always 0 (zero)
  • You can create multidimensional arrays, up to 63 dimensions
  • The index n into an array, denoted by array[n], is called the “subscript”
  • The lower bound of any array is always 0 (zero)
  • array.Length tells how many elements are in that array’s dimension
  • array.Resize is used to change the size of an array
  • If you assign a new variable to an existing array, it becomes a reference to the original array; any changes to either array are reflected in the other
  • Use array.Copy to create a new array of values
  • Stacks use .Push and .Pop to work with values
  • Queues use .Enqueue and .Dequeue to work with values
  • .Clear removes all values from Stacks and Queues
  • .Peek looks at the next available item
  • .Count gives an item count
  • Dictionaries use a “key” value to access their data
  • Dictionaries use .Add and .Remove to work with values
  • .ContainsKey and .ContainsValue allow you to search a dictionary