- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 static or fixed length arrays in C#?
A static array is a data structure with a fixed size. Let us see an example of a static array in C#.
Here is a static string array. The data remains the same here i.e. fixed −
static string[] _fruits = new string[] { "apple", "mango" };
Now let us see the complete example to create and access static arrays in C# −
Example
using System; class Demo { static void Main() { foreach (string fruits in Program.Fruits) { Console.WriteLine(fruits); } } } public static class Program { static string[] _fruits = new string[] { "apple", "mango" }; public static string[] Fruits { get { return _fruits; } } }
Advertisements