473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Begginer: How do I Load values into an array using a For Loop?

1
Can anyone tell me what would be the general staement in code to load values into an array using a For Loop?

mvalor
Nov 17 '08 #1
2 1771
vanc
211 Expert 100+
dummy code (C#)

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<array.upperbounce;i++)
  2. array[i] = value;
Nov 17 '08 #2
balabaster
797 Expert 512MB
There's an alternative to loading arrays using loops in .NET too:

VB:
Expand|Select|Wrap|Line Numbers
  1. Dim MyArray() As String = {"String1", "String2", "String3", "String4"}
C#
Expand|Select|Wrap|Line Numbers
  1. string MyArray() = {"String1", "String2", "String3", "String4"}
That's just an FYI... if you're trying to load a large array, then using this feature likely isn't going to be any help...

Just to round out the previous comment - you didn't mention if you're using c# or vb so just on the off chance you're using vb:

VB:
Expand|Select|Wrap|Line Numbers
  1. Dim MyArray(NumberOfItems) As String
  2. For i = 0 To NumberOfItems
  3.       MyArray(i) = NumberOfItems
  4. Next
Of course... an array list is easier to use:

VB:
Expand|Select|Wrap|Line Numbers
  1. Dim MyArray As New ArrayList
  2. For i = 0 To NumberOfItems
  3.     MyArray.Add("Item" & i)
  4. Next
C#:
Expand|Select|Wrap|Line Numbers
  1. ArrayList MyArray = new ArrayList;
  2. for(i = 0; i < NumberOfItems; i++)
  3.    MyArray.Add("Item"& i);
Hope that helps...
Nov 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roger Godefroy | last post by:
Hi there... I want to read fieldvalues from out of a dynamicaly created table (php). But this has to be done by JavaScript. Every row of the table has a select-box, inputbox and a order-button....
14
by: Randell D. | last post by:
Folks, Here's my problem: I am createing an array in a file using the reslut of some PHP and MySQL processing. An example of my array would be examlpe="example one"; examlpe="example...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
4
by: Jack E Leonard | last post by:
I'm looping through the keys and values of a form submission using foreach($_POST as $key => $value) echo "$key = $value<br>"; No problems there. All works as expected. But seveal of the...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
10
by: Jaye | last post by:
Hi. I am a relative newbie to ASP and I am working on an application that uses ASP and an Oracle 9i database. I have a form that allows the user to query the database by selecting a client name(s)...
4
by: noddy | last post by:
I have a mysql table called Users The userID field values start at 100 and increment up from there I am trying to transfer values from this table into a javascript array Here is what the code...
5
by: cmt | last post by:
I have an ASP report that returns values from a SQL database and formats the data in an HTML table. I am trying to figure out a good way of using CSS to highlight the table row that contains the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.