That's a really terrible way to get the value associated with the specified key!
Instead, use
the TryGetValue method[
^]:
Dictionary<int, string> dictionary = new Dictionary<int, string>
{
[1] = "0,1,2",
[3] = "1790,1234,345,67"
};
IEnumerable<string> getProductValue = dictionary.TryGetValue(3, out string value)
? value.Split(new char[] { ',' }, StringSplitOptions.None)
: Array.Empty<string>();
Better yet, if you're always returning a list of strings, change your dictionary type so that you don't need to split the string:
Dictionary<int, string[]> dictionary = new Dictionary<int, string[]>
{
[1] = ["0", "1", "2"],
[3] = ["1790", "1234", "345", "67"]
};
if (!dictionary.TryGetValue(3, out string[] getProductValue))
{
getProductValue = Array.Empty<string>();
}