I am getting error while diclaring collName as static variable in Student class.
Could any one help me finding it.
class Student
{
public int SId;
public string SName;
public Student(int SId)
{
this.SId = SId;
Console.WriteLine("Constructor is called");
}
static string coll = new string ();
cool = "RVIM"
I am getting below error.
Error 1 Invalid token '=' in class, struct, or interface member declaration C:\Users\amruthap\AppData\Local\Temporary Projects\ConsoleApplication1\Student.cs 18 14 ConsoleApplication1
Error 2 'string' does not contain a constructor that takes 0 arguments C:\Users\amruthap\AppData\Local\Temporary Projects\ConsoleApplication1\Student.cs 17 37 ConsoleApplication1
Error 3 'ConsoleApplication1.Student.coll' is a 'field' but is used like a 'type' C:\Users\amruthap\AppData\Local\Temporary Projects\ConsoleApplication1\Student.cs 18 9 ConsoleApplication1
}
Don’t call the string constructor …try treating it as a value type
static string coll = ” ” ;