473,397 Members | 2,116 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,397 software developers and data experts.

making a local variable available

I am working on code that I have posted several questions on, they have been
helpful, but as I am new to programming, I have come across something else I
am not sure how to fix. This is a build error referring to an unassigned
local variable. The problem is this variable was defined in a local
procedure and is therefore not available when I need to use it. I have
posted a bit of the code I am working on, the bit with the problems. How can
I go about reworking this code to be able to use the results of splitting the
arraylist and using the resulting array 'aFields'? Any help is very much
appreciated.

foreach (string aOutput in aColumn)
{
aFields = aOutput.Split(new char[] {' '});
}
//Define maxRow to equal the upper bound of the aFields array
maxRow = aFields.GetUpperBound(0);
//For each i less than or equal to maxRow
for (int i=0; i <= maxRow;i++)
{
//Creates new double array
AFields = new double[maxRow +1];

Nov 16 '05 #1
3 1549
Hi,

Basically you have two options:
1- Make aFields a member variable, declaring it outside any method and
inside the class
2- You may create a method that return it , in this form it can be used in
the calling method.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christine" <Ch*******@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
I am working on code that I have posted several questions on, they have been helpful, but as I am new to programming, I have come across something else I am not sure how to fix. This is a build error referring to an unassigned
local variable. The problem is this variable was defined in a local
procedure and is therefore not available when I need to use it. I have
posted a bit of the code I am working on, the bit with the problems. How can I go about reworking this code to be able to use the results of splitting the arraylist and using the resulting array 'aFields'? Any help is very much
appreciated.

foreach (string aOutput in aColumn)
{
aFields = aOutput.Split(new char[] {' '});
}
//Define maxRow to equal the upper bound of the aFields array
maxRow = aFields.GetUpperBound(0);
//For each i less than or equal to maxRow
for (int i=0; i <= maxRow;i++)
{
//Creates new double array
AFields = new double[maxRow +1];

Nov 16 '05 #2
How would I go about creating a method that returns it?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Basically you have two options:
1- Make aFields a member variable, declaring it outside any method and
inside the class
2- You may create a method that return it , in this form it can be used in
the calling method.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christine" <Ch*******@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
I am working on code that I have posted several questions on, they have

been
helpful, but as I am new to programming, I have come across something else

I
am not sure how to fix. This is a build error referring to an unassigned
local variable. The problem is this variable was defined in a local
procedure and is therefore not available when I need to use it. I have
posted a bit of the code I am working on, the bit with the problems. How

can
I go about reworking this code to be able to use the results of splitting

the
arraylist and using the resulting array 'aFields'? Any help is very much
appreciated.

foreach (string aOutput in aColumn)
{
aFields = aOutput.Split(new char[] {' '});
}
//Define maxRow to equal the upper bound of the aFields array
maxRow = aFields.GetUpperBound(0);
//For each i less than or equal to maxRow
for (int i=0; i <= maxRow;i++)
{
//Creates new double array
AFields = new double[maxRow +1];


Nov 16 '05 #3
Given that aFields has become a member variable it goes something like this:

class Joepie
{
private ArrayList aFields;

public ArrayList MyFields
{
get { return aFields; }
}

}
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christopher Jeris | last post by:
I am relatively new to JavaScript, though not to programming, and I'm having trouble finding the idiomatic JS solution to the following problem. I have a table with (say) fields f1, f2, f3. I...
4
by: subramanian100in | last post by:
I read in C++ Primer 4th Edition by Stanley Lippman, in page 57, that const variables at global scope are local to a file by default. What is the advantage of this rule ? Suppose I have the...
204
by: Masood | last post by:
I know that this topic may inflame the "C language Taleban", but is there any prospect of some of the neat features of C++ getting incorporated in C? No I am not talking out the OO stuff. I am...
5
by: Andy B | last post by:
I am trying to figure out how to make an object instance available for all methods of a class. I tried to do something like this: public class test { TheObject Instance = new TheObject();...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.