Any advantage or difference in using const or Func in a class ?
public sealed class Constants {
private Constants() {}
public const string SOME_STRING = "Some String";
public static Func<string> SomeString = () => "Some String";
}
Debug.WriteLine(Constants.SOME_STRING);
Debug.WriteLine(Constants.SomeString());
For what you’ve shown, use a
const. Your intent is clear that way.A
Funcis just a function, represented as an object. You don’t seem to need a function, so why use one? A direct access is simpler to understand and more people will expect it. If I saw that usage of a Func, I would definitely do a double take.