I just finished up reading on structs in C#.
I still do not understand why it is not possible to initialise instance fields in a struct but it is possible to initialise static fields?
To make my question clearer, why does this give an error:
and this doesn't:
I still do not understand why it is not possible to initialise instance fields in a struct but it is possible to initialise static fields?
To make my question clearer, why does this give an error:
C#:
using System;
namespace Sample
{
struct Animal
{
private string name = "Adam";
}
}
and this doesn't:
C#:
using System;
namespace Sample
{
struct Animal
{
private static string name = "Adam";
}
}