I have some libraries that contain a large number of constants. Any application that uses the library will use some or none of those constants. So, I was wondering whether using lambda expressions (for example):
public static Milliseconds {
public static int OneSecond => 1000;
public static int TwoSeconds => 2000;
.
.
}
would be more efficient either in terms of file sizes (exe or dll) or run-time speed than:
public static Milliseconds {
public const int OneSecond = 1000;
public const int TwoSeconds = 2000;
.
.
}
I'm sure any differences would be minimal. I'm not looking to squeeze the last byte or nano-second out, I'm just curious. Thank you.
constvalues then any consuming libraries will need to be recompiled also. From the context of your values this looks like it would be unlikely for you but it's something that has caught me out in the past.constwill be faster at run time because the calling library won't even go into your assembly afaik.