T
tshad
Why does this not work?
Can't I call a function directly from within a class? I also tried this
with public in place of private.
I get the following error:
An object reference is required for the nonstatic field, method, or property
'MultiNamespaces.Class1.displayHeadline()'
The code is:
using System;
namespace MultiNamespaces
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
displayHeadline(); <-- The error
Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}
private void displayHeadline()
{
Console.WriteLine("a test");
}
}
}
Thanks,
Tom
Can't I call a function directly from within a class? I also tried this
with public in place of private.
I get the following error:
An object reference is required for the nonstatic field, method, or property
'MultiNamespaces.Class1.displayHeadline()'
The code is:
using System;
namespace MultiNamespaces
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
displayHeadline(); <-- The error
Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}
private void displayHeadline()
{
Console.WriteLine("a test");
}
}
}
Thanks,
Tom