I started to learn C #. I am trying to declare a class and some variables and try to perform simple string concatenation. But I get some error - the code below
namespace ConsoleApplication1
{
class Class1
{
string s1 = "hi";
string s2 = "hi";
string s3 = s1 + s2;
}
}
The error I get is that the
Field Initializer cannot reference non-static fields, method, property 'ConsoleApplication1.Class1.s1
Can someone explain what is happening here.
Thank.
source
share