

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are good examples of array in C#?
An array is used to store a collection of data. It consists of contiguous memory locations.
Some of the examples of the array include −
Find common elements in three sorted arrays
using System; class Demo { static void commonElements(int []one, int []two, int []three) { int i = 0, j = 0, k = 0; while (i < one.Length && j < two.Length && k < three.Length) { if (one[i] == two[j] && two[j] == three[k]) { Console.Write(one[i] + " "); i++;j++;k++; } else if (one[i] < two[j]) i++; else if (two[j] < three[k]) j++; else k++; } } public static void Main() { int []one = {20, 35, 57, 70}; int []two = {9, 35, 57, 70, 92}; int []three = {25, 35, 55, 57, 67, 70}; Console.Write("Common elements: "); commonElements(one, two, three); } }
Create Arrays Dynamically in C#
using System; using System.Collections; namespace CollectionApplication { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); al.Add(99); al.Add(47); al.Add(64); Console.WriteLine("Count: {0}", al.Count); Console.Write("List: "); foreach (int i in al) { Console.Write(i + " "); } Console.WriteLine(); Console.ReadKey(); } } }
Work with Jagged Arrays and access an element in C#
using System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int[][] points = new int[][]{new int[]{10,5},new int[]{30,40}, new int[]{70,80},new int[]{ 60, 70 }}; int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0}][{1}] = {2}", i, j, points[i][j]); } } // access int x = points[0][1]; Console.WriteLine(x); Console.ReadKey(); } } }
- Related Questions & Answers
- What are the properties of a good Heating Element?
- What are the examples of Unsupervised Learning?
- What are Good and Bad Interface Designs?
- What are the popular examples of Block Cipher?
- What are the examples of clustering in data mining?
- What are the good resources to Learn C++?
- What Vitamins are good to prevent hair loss?
- What are some good educational activities for teenagers?
- What are some good uses of NEEM plant that you know?
- What are some basic examples of Python Regular Expressions?
- What are the examples of Data Link Layer Protocols?
- What are some good sites for Java interview questions
- What are some good ways to relieve holiday stress?
- What are the indications of Diarrhea in babies? Suggest some good treatment options.
- What are the advantages of drinking wine? Is it really good for health?
Advertisements