Pretty new to C# and OOP. I am trying to create a class called "Human" with some information initialization. However I get the following error a field initializer cannot reference the nonstatic field method or property
. The error message points at first_name and last_name when trying to create the full_name
variable
Heres the "simple" code
namespace World
{
public class Human
{
// Personal traits
public string first_name;
public string last_name;
public string full_name = first_name + " " + last_name;
}
}
What exactly am I doing wrong? I dont get it..