GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • About
  • Reference
  • Integrations
  • API
  • Blog
  • C# Syntax Reference
  • Feedback

This view

  • Original page
  • New address

GeezerVison is showing syntaxdb.com — Arrays in C# - SyntaxDB - C# Syntax Reference

  • Java
  • C
  • C++
  • C#
  • Python
  • Ruby
  • JavaScript
  • Swift
  • Go
Languages
    • User Program Communication
      • Write to Console
      • Commenting
      • User Input
      • Read from File
      • Write to File
      • Namespace
    • Variables
      • Primitive Data Types
      • Variable Declaration
      • Parse
      • Constants
      • Pointers and References
      • Arrays
      • Lists
      • Dictionaries
      • Type Conversion
      • Structures
    • Control Flow
      • If Statement
      • Switch Case
      • For Loop
      • For Each
      • While Loop
      • Do While Loop
      • Try Catch Block
    • Object Oriented Programming
      • Class Declaration and Structure
      • Access Modifiers
      • Class Variables
      • Standard Methods
      • Static Methods
      • Constructor
      • Instantiation
      • Interfaces
      • Abstract Methods and Classes
      • Inheritance
    • Strings
      • String Variables
      • String Length
      • String Compare
      • String Trim
      • String Split
      • String Representation
Categories
Language
C#
  • Java
  • C
  • C++
  • C#
  • Python
  • Ruby
  • JavaScript
  • Swift
  • Go
Version: 5

Categories

  • User Program Communication
    • Write to Console
    • Commenting
    • User Input
    • Read from File
    • Write to File
    • Namespace
  • Variables
    • Primitive Data Types
    • Variable Declaration
    • Parse
    • Constants
    • Pointers and References
    • Arrays
    • Lists
    • Dictionaries
    • Type Conversion
    • Structures
  • Control Flow
    • If Statement
    • Switch Case
    • For Loop
    • For Each
    • While Loop
    • Do While Loop
    • Try Catch Block
  • Object Oriented Programming
    • Class Declaration and Structure
    • Access Modifiers
    • Class Variables
    • Standard Methods
    • Static Methods
    • Constructor
    • Instantiation
    • Interfaces
    • Abstract Methods and Classes
    • Inheritance
  • Strings
    • String Variables
    • String Length
    • String Compare
    • String Trim
    • String Split
    • String Representation

Variables

Arrays in C#

An array is used to assign a series of elements of the same type in consecutive memory locations; to define a list of elements.


Syntax
dataType[] arrayName = new dataType[arraySize]; 
dataType[] arrayName = {values,..,…};
dataType[,] arrayName = new dataType[rows, columns]; 
dataType[][] arrayName = new dataType[rows][columns];

arrayName[elementPosition] = arrayElement; 
//To set a value at a specific position in the array 

variableType Variable = arrayName[elementPosition]; 
//To access a specific element and store in a variable. 

Notes

dataType can be any C# data type, all elements in the array must be of this data type. arrayName is defined by the programmer. arraySize and elementPosition are integers.

The index value (elementPositions) starts at 0.


Example
int[] array = {1,2,3}; 
array[4] = 4; //Note: new array is = {1,2,3,0,4} 
int startValue = array[0];

Add to Slack

< Pointers and References   |   Lists >


You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.