i have a class and have declared an enum in it like
public enum file_type {readonly, readwrite, system}
Now based on a condition i want to set the enum file_type to a value something like
if("file is markedreadonly")
file_type = readonly;
is it possible to do so in c#
By writing file_type = readonly, you are trying to change the definition of an Enum at runtime, which is not allowed.
Create variable of type file_type and then set it to readonly.
Also, please use .NET naming standards to name your variable and types. Additionally for Enums, it is recommended to have a ‘None’ enum as the first value.