471,066 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Accessing data from a class in main form(program)

2
I have a C#.Net program that once a button is clicked it goes to a public class(called Tal) and gets data in a vector, then exits the class, and goes back to the main form(program). I will do this task over and over. I want to take the data ,do many(over 20) calculations, and go back to the program. How can I get access to the data array(vector) from the main program? I keep getting different errors and have tried so many different ways. Thanks in advance.

Code:
{
Mainfrm

tal.talbars();
}

Public Class tal

// get vector array
Price[] closes = row["SETTLE"] == null ? null : row SETTLE"].PriceVectorValue;
int first_element = elements - 5; // to get 5 back
for (int i = first_element; i < elements; i++)

static void talbars

tal();

So I want to use closes[1-5] in the main program. I get not in namespace error(I put the whole class in the main form, so that shouldnt be an issue). I get name doesnt exist in class also. Any ideas would be greatly appreciated.
Nov 1 '06 #1
2 1102
mdaRock
26
Could you please explain more or resubmit your code with proper scope charater {}

Regards.

I have a C#.Net program that once a button is clicked it goes to a public class(called Tal) and gets data in a vector, then exits the class, and goes back to the main form(program). I will do this task over and over. I want to take the data ,do many(over 20) calculations, and go back to the program. How can I get access to the data array(vector) from the main program? I keep getting different errors and have tried so many different ways. Thanks in advance.

Code:
{
Mainfrm

tal.talbars();
}

Public Class tal

// get vector array
Price[] closes = row["SETTLE"] == null ? null : row SETTLE"].PriceVectorValue;
int first_element = elements - 5; // to get 5 back
for (int i = first_element; i < elements; i++)

static void talbars

tal();

So I want to use closes[1-5] in the main program. I get not in namespace error(I put the whole class in the main form, so that shouldnt be an issue). I get name doesnt exist in class also. Any ideas would be greatly appreciated.
Nov 1 '06 #2
dkoco
2
I will make it more basic.

Namespace Program
{
Main()
{
class.tal; // goto class to get data
double calc;
calc = data[1]+data[2];
Console.Writeline(calc);
} //end of Main

Public Class Class()

public void tal
{
// get data for data[1] and data[2]
} // end of class.tal
} // end namespace

I will have alot of data[] and a lot of calcs to be done in the main(cant be done in class). So I get errors when I try and use data[] in Main. Im new to C# and I know its something simple, I just cant figure it out. Thanks again.
Nov 1 '06 #3

Post your reply

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

Similar topics

3 posts views Thread by Reimar Bauer | last post: by
reply views Thread by Josef | last post: by
2 posts views Thread by martinnitram | last post: by
1 post views Thread by Toondalis | last post: by
1 post views Thread by Peter | last post: by
1 post views Thread by Toondalis | last post: by
11 posts views Thread by seattleboatguy | last post: by
reply views Thread by leo001 | last post: by

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.