I have been writing code without realizing WHY I can access constant values within static
methods.
Why is it possible to access const
values without declaring it as static
?
E.g.) It's legal to call IMAGE_FILE_EXTENSION
within AddImageToDocument(...)
public abstract class ImageDocumentReplacer : DocumentReplacer
{
private const string IMAGE_FILE_EXTENSION = ".tif";
private static void AddImageToDocument(int documentId, string separatedPath)
{
Console.WriteLine(IMAGE_FILE_EXTENSION);
}
}