1 / 23

C# Arrays Tutorial | C# Tutorial For Beginners | How To Program C# Arrays |

This slide on C# Arrays tutorial will acquaint you with a clear understanding of the fundamentals of C# Arrays. In this C# Tutorial for beginners, you will get better understanding on how to program arrays. we will start with an introduction to C# Arrays, then we will look into types of C# Arrays like single dimensional, multi dimensional and jagged C# arrays. Finally, we will cover the advantages and disadvantages of C# arrays.<br>

Simplilearn
Download Presentation

C# Arrays Tutorial | C# Tutorial For Beginners | How To Program C# Arrays |

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda

  2. Agenda • What is C# Arrays? • Types of C# Arrays • Advantages of C# Arrays • Disadvantages of C# Arrays • Conclusion

  3. Click here to watch the video

  4. What is C# Arrays?

  5. What is C# Arrays? In C#, an array is a collection of elements of the same type that are stored in the same memory location

  6. What is C# Arrays? In C#, array is an object of base type "System.Array". The array index in C# starts at 0. In a C# array, we can only store a fixed number of elements.

  7. Types of C# Arrays

  8. Types of C# Arrays

  9. Single Dimensional Array

  10. Single Dimensional C# Array To create single dimensional array, you need to use square brackets [] after the type. int[] arr = newint[5];//creating array   arr[0] = 10;//initializing array  

  11. Multi-Dimensional Array

  12. Multi-Dimensional Array To create multidimensional array, we need to use comma inside the square brackets. int[,] arr=newint[3,3]; //declaration of 2D array   int[,,] arr=newint[3,3,3]; //declaration of 3D array

  13. Jagged Array

  14. Jagged Array Jagged array is also known as a "array of arrays" in C# since each of its elements is an array. A jagged array's element size might vary. int[][] arr = newint[2][];  

  15. Advantages

  16. Advantages It is used to represent numerous data objects of similar kind with a single name. Data structures, like linked lists, trees, stacks, and queues, are implemented using arrays. The two-dimensional arrays in C# are used to represent matrices. Since arrays are strongly typed, the program's performance is improved because of no boxing and unboxing.

  17. Disadvantages

  18. Disadvantages The array size is fixed. So, we must declare the size of array beforehand. If we allocate more memory than the requirement then the extra memory will be wasted. An element can never be inserted in the middle of an array. It is also not possible to delete or remove elements from the middle of an array.

  19. Conclusion

  20. Conclusion Code Optimization is very easy in C# Arrays. It is easy to traverse data using C# Arrays. It is easy to manipulate data using C# Arrays. It is easy to sort data using C# Arrays. Since arrays have a fixed size, declaring it may result in memory waste or shortage.

More Related