Preview

Data Type and Array

Better Essays
Open Document
Open Document
760 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Data Type and Array
How to use array in c# 5

Introduction
In this tutorial I am going to explain about these questions answer below help of example in c# in visual studio 2012. 1. What is array? 2. How to declare an array in c# or How to Initializing Array? 3. How to assigning values to the array in c# ? 4. How to use array in c# with example? 5. How to find even odd numbers in c# using array?
What is array?
An array is a collection of values of the same data type. The variables in an array are called the array elements. Array elements are accessed using a single name and an index number representing the position of the element within the array. Array is a reference type data type.
The following figure shows the array structure in the system’s memory:

An array needs to be declared before it can be used in a program. You can declare an array by using the following statement: Source code | | int[] Score; int[] Score; |
How to declare an array in c# with example step by step tutorial
The following is an example of the array declaration:

The explanation of the elements of the preceding statement is as follows: datatype[] Arrayname; | * datatype: Is used to specify the data type for the elements, which will be stored in the array. * [ ]: Is used to specify the rank of the array. Rank is used to specify the size of the array. * Arrayname: Is used to specify the name of the array using which the elements of the array will be initialized and manipulated.
Initializing Array:-
Array is a reference type, therefore you need to use the new keyword to create an instance of the array. The following statement is an example of array initialization:
The preceding two statements can be combined into a single statement, and written, as follows: Source code | | int[] Score = new int[10];
In C#, the array subscript always starts with zero.
Assigning values to the array:-
You can assign values to each

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Assignment 2

    • 338 Words
    • 2 Pages

    You are not allowed to use ArrayLists or Vectors, only primitive arrays or string arrays if you want.…

    • 338 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    3. Write assignment statements that perform the following operations with the variables a, b, and c.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    It 218 Week 4 Checkpoint

    • 290 Words
    • 2 Pages

    An array is a variable that holds more than more than one value, and an array can be combined with multiple variables for a more complex structure. An array is declared much similar with any other variable. The only difference is the number of elements is shown in brackets. An example of an array will be look much like these three: calories [ min ], 30 [ 7 ], and feet [ 12 ]. Each one of these arrays can be used as long as it is appropriate for the program.…

    • 290 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    “An array is a collective name given to a group of similar quantities. These similar quantities could be percentage marks of 100 students, number of chairs in home, or salaries of 300 employees or ages of 25 students. Thus an array is a collection of similar elements. These similar elements could be all integers or all characters, and so on” (Thompson, 2007). Building an array can be confusing for the Bug Blasters can be very confusing for a programmer who does not fully understand how they work.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Arrays store items that have the same type of data type like a group of employees’ names and social security numbers for a team of 2000 personal. Pointer is a variable that greatly extends the power and flexibility of a program, each memory location that is used to store data value has an address. The address provides the means for a PC hardware to reference a particular data item.…

    • 485 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    2. What is the term used for the number inside the bracket that specifies the number of values that an array can hold? (Points : 7)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Prg 211 Array Structure

    • 788 Words
    • 4 Pages

    During the development of the Naming Scheme program for the Quality Review Measurement staff, additional naming schemes were discussed for future revisions to the program. The current program only allows the inputs that relate to the file names for the Conference Call notes. There are additional files not related to the conference calls that will benefit from the use of a naming scheme. For consideration, the following file groups will be added in the next revision of the Naming Scheme: Monthly Executive Report, Quarterly Executive Report, Annual Executive Report, and the EQRS Monthly Analysis (per Product Line).…

    • 788 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    E4.6: The label array_x is the starting address of an array of 100 8bit elements.…

    • 900 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cis121 chapter 2 and 3

    • 993 Words
    • 6 Pages

    ____ is where a variable's data type or other information is stored as part of the name.…

    • 993 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    j. The set of all strings consisting of an open bracket (the symbol [) followed by a list of one or more digits separated by commas, followed by a closing bracket (the symbol ]).…

    • 470 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Array Structure Proposal

    • 574 Words
    • 3 Pages

    An array is a variable that holds multiple values of the same kind. Nearly every…

    • 574 Words
    • 3 Pages
    Good Essays
  • Better Essays

    E-Commerce Exercise

    • 1068 Words
    • 5 Pages

    1. As an object, a String variable name is not a simple data type. It is a(n) ____; that is, a variable that holds a memory address.…

    • 1068 Words
    • 5 Pages
    Better Essays
  • Satisfactory Essays

    carloe :)

    • 253 Words
    • 2 Pages

    Problem 1. a) Write an application that can hold five integers in an array. Display the integers from first to last, and then display the integers from last to first.…

    • 253 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Data Structure

    • 328 Words
    • 2 Pages

    How do you create an instruction that steps through an array, performing an operation on each item?…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    The Last Ride Together

    • 666 Words
    • 3 Pages

    Write a program to input a start limit S (S>0) and the last limit L (L>0). Print all the prime triplets between S and L (both inclusive), if S<=L otherwise your program should ask to re-enter the values of S and L again with a suitable error message.…

    • 666 Words
    • 3 Pages
    Good Essays