|
-
Dec 14th, 2009, 10:20 PM
#1
Thread Starter
Interweb adm/o/distrator
[RESOLVED] Simple but weird error...
"An object reference is required for the non-static field, method, or property 'Test.Program.t'"
I am getting errors like that in the Main method of my test class.
Code:
public class Program
{
double time = 1; //second
int t = 100;
int i = 10;
int j = 10;
static void Main(string[] args)
{
Temperatures temps = new Temperatures(time, t, i, j);
if (temps.stability()<=0.5)
Console.WriteLine("Stability = "+temps.stability()+ " < 0.5");
else
Console.WriteLine("UNSTABLE!!! Stability = " +temps.stability());
Console.WriteLine("dx = "+temps.dx()+" m");
Console.WriteLine("dy = "+temps.dy()+" m");
Console.WriteLine("dt = "+temps.dt()+" s");
Console.WriteLine("LambdaX = "+ temps.lX());
Console.WriteLine("LambdaY = "+ temps.lY());
Console.WriteLine(" ");
// Console.WriteLine("Bottom-Left corner = "+temps.profile()[t,i,j]+" C.");
// Console.WriteLine("Center-point = "+temps.profile()[t,i/2,j/2]+" C.");
for (int l = 0; l<=t; l++)
{
for (int m = 0; m<=i; m++)
{
for (int n = 0; n<=j; n++)
{
Console.WriteLine(temps.profile()[l,m,n]);
}
}
}
}
}
There is the code, Bolded characters are the problems.
-
Dec 14th, 2009, 10:26 PM
#2
Thread Starter
Interweb adm/o/distrator
Re: Simple but weird error...
Fixed... i forgot the members needed to be static -.- sorry this was a conversion from an old java project got a bit lost and removed the final keyword without changing it to static -.-
Thanks anyways.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|