What is the cause of the error on the screen?
public struct YetkiYapisiListesi
{
public bool STOKGUNCELLE =false ;
public bool STOKSIL=false;
public bool STOKLISTELE=false;
}
Non-static struct member cannot have initializer
What is the cause of the error on the screen?
public struct YetkiYapisiListesi
{
public bool STOKGUNCELLE =false ;
public bool STOKSIL=false;
public bool STOKLISTELE=false;
}
Non-static struct member cannot have initializer
C# does not allow struct
s to have initializers, the reason why has been debated before, see here: ( Why can't I initialize my fields in my structs? )
Simply remove the = false
part from your field declarations.
Note that Boolean
fields are false
by default, making your assignment completely unnecessary.
If you absolutely need fields to have initialized to non-default values then you can still define an additional constructor that sets those values, however it cannot be the default (parameterless) constructor. One alternative option then, is to use a static factory method.
You can't initialize field on Struct.
You will get the same result even if you ommit initializing :
public bool STOKGUNCELLE;
public bool STOKSIL;
public bool STOKLISTELE;
public bool STOKHAREKET;
Because bool default value are false .