I have the following code:
public string GetRefStat(string pk) {
return RefStat[pk.Substring(2, 2)];
}
private readonly Dictionary<String, int> RefStat =
new Dictionary<string, int>
{
{"00", REF.MenuType, } // Menu
{"01", REF.ReferenceStatus,} // Article
{"02", REF.ReferenceStatus,} // Favorites List
{"03", REF.ReferenceStatus,} // Content Block
{"06", REF.ReferenceStatus } // Topic
};
GetRefStat and the dictionary are always used together.
Is there a way I could simplify and combine these? I was wondering if I could put the information in a static class and then have a get method that returned the information I needed.
int
s, but the method returnsstring
s. Also, some commas in your definition of the dictionary are misplaced (they should outside the braces, not inside). \$\endgroup\$