Consider, class test
Step 1-->
public class test
{
private string temp_err=string.Empty;
public static void GetResult()
{
temp_err="abc";
}
}
Step 2-->
public class test
{
private String temp=string.Empty;
public static void GetResult()
{
temp="abc";
}
}
In case of Step 1 an error is coming: Cannot access non-static field in static context.
but when I've changed my code like in case of Step 2 everything is working fine.
Kindly explain what is the difference between string and String..
On google, it is written that string is the alias of System.String which describes there is no such difference.
Please guys before selecting this question in possible duplicate category. Read all the 41 answers given on that url and then take some decision. I'm asking about there behavior in Static method. Please read the question again