Keeping enums in separate script files

时间:2018-02-03 09:07:29

标签: c# enums

I have been keeping my enums in separate scripts instead like this...

public enum PrefabID { Pistol, SubmachineGun, HMG, }

Instead of doing this...

public class Shooter
{
  public enum PrefabID { Pistol, SubmachineGun, HMG, }    
}

does this have any compile time penalties (increase the compile time) or it does increase the built executable size?

I'm using C#

1 个答案:

答案 0 :(得分:1)

It seems that the compile times remains the same whether there are more script files for the enums or there are enums inside another class script. Both this...

public enum PrefabID { Pistol, SubmachineGun, HMG, }

and this...

public class Shooter
{
  public enum PrefabID { Pistol, SubmachineGun, HMG, }    
}

doesn't harm the compile time in any way, But the size is definitely affected as the the first style increases the built executable size by a few bytes but the second style doesn't.