H
H
Ok, this is my code (yep my first program.....)
class MyClass{
private int b(int i)
{
i = 34;
return i;
}
static void Main()
{
Console.WriteLine("Hej");
int a = 3;
int hello = b(a);
}
}
and this won't compile... I get error CS0120 "An objectreferense is needed
for the non-static field, method or attribute MyClass.b(int)"
(maybe not the best translation, but it'll have to do...)
In every example and in my book this is said to be ok, but not for my
compiler. So what am I doing wrong ? If i make b() static it works, why ?
Exactly what does static do ?
TIA
class MyClass{
private int b(int i)
{
i = 34;
return i;
}
static void Main()
{
Console.WriteLine("Hej");
int a = 3;
int hello = b(a);
}
}
and this won't compile... I get error CS0120 "An objectreferense is needed
for the non-static field, method or attribute MyClass.b(int)"
(maybe not the best translation, but it'll have to do...)
In every example and in my book this is said to be ok, but not for my
compiler. So what am I doing wrong ? If i make b() static it works, why ?
Exactly what does static do ?
TIA