Sorry if the wording of this question is incorrect; I'm coming from a Javascript/Typescript background.
What I'm looking to create is a set of key/value pairs which is immutable, where the IDE/compiler would know which keys are or aren't present in that list. I presume this is possible with a class, and maybe this is really the best option, but I'm interested to understand whether there are alternatives.
For instance, for the config of an application, in Typescript I could have:
const config = { applicationName: 'Some application', port: 8000, }; const testOne = config.applicationName; const testTwo = config.fail; // this would not work That is to say, the compiler, or some interpreter which the IDE uses, is able to tell based on the structure that a key/value does not exist for that structure.
It seems to me that a class is excessive for this kind of data; though as I'm relatively new to the language, this may be due to my naivety. I'd like to know if there's a structure within C# that can store keys and values, in an immutable way, and know at compile time whether or not a key/value pair is available in that collection.
myObj.PropertyThatDoesExistthe IDE will show you the error?