You haven't initialized or specified the length of the array. You need to specify the length for the Array to create one, but in your case you don't know that info in advance
So you can use a List instead
var invalidKeys = new List<String>();
foreach (string key in ConfigurationManager.AppSettings.Keys)
{
string value = ConfigurationManager.AppSettings[key];
if (IsValidBooleanString(value) == false)
{
//Add 'key' to next empty index in the array 'invalidKeys'.
invalidKeys.Add(key);
}
return invalidKeys;
Also noticed your foreach should be on ConfigurationManager.AppSettings.Keys not ConfigurationManager.AppSettings
Other way of doing this will be
var invalidKeys =
ConfigurationManager.AppSettings.Keys
.Where(k => IsValidBooleanString(ConfigurationManager.AppSettings[k]) == false)
.ToArray();