I have a situation in code where a Dictionary<string, string>
seemed like the best idea - I need a collection of these objects and I need them to be accessible via a unique key. Exactly what the Dictionary concept is for, right?
Well, the requirements have expanded to the point where I now need to hold an additional bit of information per-key (a boolean value, if you're curious).
So, I figure expand the concept to create a new data structure with the string and the boolean and have it now be a Dictionary<string, NewCustomObject>
.
However, for just one additional value like a boolean flag, it just feels like overkill. And yet I don't know of any Dictionary-like generic object with two values per key.
Is just having a Dictionary of custom objects the best way to go about this or is there something simpler for this scenario?
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Quote from wikipedia: "A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix." The creators want that everyone "see" his language. So he named it "C".
noun plural c's, C's or Cs. the third letter and second consonant of the modern English alphabet. a speech sound represented by this letter, in English usually either a voiceless alveolar fricative, as in cigar, or a voiceless velar stop, as in case.
Actually, what you've just described is an ideal use for the Dictionary collection. It's supposed to contain key:value pairs, regardless of the type of value. By making the value its own class, you'll be able to extend it easily in the future, should the need arise.
class MappedValue { public string SomeString { get; set; } public bool SomeBool { get; set; } } Dictionary<string, MappedValue> myList = new Dictionary<string, MappedValue>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With