In C#, why won’t the following work? I get an error: “An objectreference is required for the non-static field, method, orproperty”.
public void StudentNames(string student)
{
Console.WriteLine($”{student}”);
}
static void Main(string[] args)
{
string student = “John Doe”;
string whatever = StudentNames(student);
// some other code
}
Expert Answer
An answer will be send to you shortly. . . . .