This question is locked. New answers and comments are not allowed.
Hi,
i have the follwoing interesting issue:
if i use a struct, i get a warningthat the field is never assigned.
Example:
if i change "private static Test test1;" to "public static Test test1;"the warning goes away.
Why do I get the warning? The struct has no ctor. I could put a new call in the file so that the warning goes away "test1 = new Test();" .
But why should it be needed? And why shouldn't it be needed if the field is public instead of private?
Best regards,
Wolfgang
i have the follwoing interesting issue:
if i use a struct, i get a warningthat the field is never assigned.
Example:
public struct Test{ public int Prop1 { get; set; }} class Program{ private static Test test1; // Justcode warning: Field 'xyz' is never assigned static void Main(string[] args) { test1.Prop1 = 1; }}if i change "private static Test test1;" to "public static Test test1;"the warning goes away.
Why do I get the warning? The struct has no ctor. I could put a new call in the file so that the warning goes away "test1 = new Test();" .
But why should it be needed? And why shouldn't it be needed if the field is public instead of private?
Best regards,
Wolfgang