iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Add Items to an Array in ASP

104 30
    • 1). Create your array variable. You cannot use variables until they are defined in your code. The following instructions show you how to create an array variable for a group of strings and integers:

      string arrayStrings[] = new string[2];

      int arrayIntegers[] = new int[2];

      In these array variables, each array allows for two values.

    • 2). Add some value to the string array. Since you define "arrayStrings" as a group of string values, you can only add string values to the array. The following code shows you how to add strings:

      arrayStrings[0] = "orange";

      arrayStrings[1] = "purple";

      Notice the first value is the "0" entry in the array. Arrays start with the "0" index. Therefore, if you allow for two values, your array starts with the "0" index and ends with the "1" index.

    • 3). Add values to the integer array. Like the string array, only integers can be added to an integer array. The following code shows you how to add integers to an array:

      arrayIntegers[0] = 12;

      arrayIntegers[1] = 13;

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.