Quickest way, by getting the IList<string>
from the dictionary and accessing its seventh element:
checksCollection[checkName][6] = "new value";
But if I were you, I'd make all those values in the string array its own class so you don't have to hardcode the index values, just in case you add or remove additional properties in the future. Create a class definition like so:
public class YourClass
{
public string CheckName { get; set; }
public string HostName { get; set; }
public string Port { get; set; }
public string PollInterval { get; set; }
public string AlertEmail { get; set; }
public string AlertSMS { get; set; }
public string AlertURI { get; set; }
}
And change your dictionary definition:
public static IDictionary<string, YourClass> checksCollection =
new Dictionary<string, YourClass>();
And then to add to it (although preferably you would create a constructor on YourClass
that takes the parameters):
public static void addCheck(string checkName, string hostName, string port, string pollInterval, string alertEmail, string alertSMS, string alertURI)
{
checksCollection.Add(checkName, new YourClass() {
CheckName = checkName,
HostName = hostName,
Port = port,
PollInterval = pollInterval,
AlertEmail = alertEmail,
AlertSMS = alertSMS,
AlertURI = alertURI
});
}
And then modifying becomes straightforward with no guesswork of array indices:
checksCollection[checkName].AlertURI = "new value";