error :(

S

sahel

Hi;
I write a program that it has error do u know how I could solve it
(& I don’t want public lastname)

using System;

namespace ConsoleApplication49
{
class Program
{
static void Main(string[] args)
{
info.Employee();
}
class info
{
private string[] lastname = new string[100];
static public void Employee()
{
for (int i = 0; i <3; i++)
{
Console.WriteLine("enter the last name :");
lastname = Console.ReadLine();
}
}
}
}
}
That error is here:

Error 1 An object reference is required for the non-static field,
method, or property 'ConsoleApplication49.Program.info.lastname'
 
A

Arne Vajhøj

I write a program that it has error do u know how I could solve it
(& I don’t want public lastname)

using System;

namespace ConsoleApplication49
{
class Program
{
static void Main(string[] args)
{
info.Employee();
}
class info
{
private string[] lastname = new string[100];
static public void Employee()
{
for (int i = 0; i<3; i++)
{
Console.WriteLine("enter the last name :");
lastname = Console.ReadLine();
}
}
}
}
}
That error is here:

Error 1 An object reference is required for the non-static field,
method, or property 'ConsoleApplication49.Program.info.lastname'


The error text explains the problem.

You access a non-static field from a static method.

Arne
 
S

sahel

I write a program that it has error do u know how I could solve it
(&  I don’t want public lastname)
using System;
namespace ConsoleApplication49
{
     class Program
     {
         static void Main(string[] args)
         {
             info.Employee();
         }
         class info
         {
             private string[] lastname = new string[100];
             static public void Employee()
             {
                 for (int i = 0; i<3; i++)
                 {
                     Console.WriteLine("enter thelast name :");
                     lastname = Console.ReadLine();
                 }
             }
         }
     }
}
That error is here:

Error      1       An object reference is required for the non-static field,
method, or property 'ConsoleApplication49.Program.info.lastname'

The error text explains the problem.

You access a non-static field from a static method.

Arne


i do n0t get how to solve it
u know i am new at programing
 
A

Arne Vajhøj

I write a program that it has error do u know how I could solve it
(& I don’t want public lastname)
using System;
namespace ConsoleApplication49
{
class Program
{
static void Main(string[] args)
{
info.Employee();
}
class info
{
private string[] lastname = new string[100];
static public void Employee()
{
for (int i = 0; i<3; i++)
{
Console.WriteLine("enter the last name :");
lastname = Console.ReadLine();
}
}
}
}
}
That error is here:

Error 1 An object reference is required for the non-static field,
method, or property 'ConsoleApplication49.Program.info.lastname'

The error text explains the problem.

You access a non-static field from a static method.


i do n0t get how to solve it
u know i am new at programing


You could make lastname static.

But I really think you need to read a solid book about C#.

Arne
 
S

sahel

On 05-03-2010 11:49, sahel wrote:
I write a program that it has error do u know how I could solve it
(&    I don’t want public lastname)
using System;
namespace ConsoleApplication49
{
      class Program
      {
          static void Main(string[] args)
          {
              info.Employee();
          }
          class info
          {
              private string[] lastname = new string[100];
              static public void Employee()
              {
                  for (int i = 0; i<3; i++)
                  {
                      Console.WriteLine("enter the last name :");
                      lastname = Console.ReadLine();
                  }
              }
          }
      }
}
That error is here:
Error      1       An object reference is required for the non-static field,
method, or property 'ConsoleApplication49.Program.info.lastname'
The error text explains the problem.
You access a non-static field from a static method.

i do n0t get how to solve it
u know i am new at programing

You could make lastname static.

But I really think you need to read a solid book about C#.

Arne


thanks Arne i get;
merc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top