Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:10:02+00:00 2026-06-06T05:10:02+00:00

I have a dictionary public static IDictionary<string, IList<string>> checksCollection = new Dictionary<string, IList<string>>(); I

  • 0

I have a dictionary

public static IDictionary<string, IList<string>> checksCollection = 
           new Dictionary<string, IList<string>>();

I add to the dictionary as follows:

public static void addCheck(string checkName, string hostName, 
          string port, string pollInterval, string alertEmail, 
          string alertSMS, string alertURI)
{
    checksCollection.Add(checkName, new[] { checkName, hostName, port, 
               pollInterval, alertEmail, alertSMS, alertURI });
}

How would it be possible to change the alertURI list value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:10:04+00:00Added an answer on June 6, 2026 at 5:10 am

    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";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public static class ScraperMasterUriDetails { public static Dictionary<Guid, string>
I am using EF 4 and have the following code. public static Dictionary<Tuple<int, string>,
I have the following classes: public class DictionaryBuilder<T> where T : IDictionary<string, object>, new()
Say I have the following dictionary like so: public static Dictionary<Type, string> nullableTypeToStringMap =
I have dictionaries. First I initialize them. public Dictionary<string, Bitmap> lookup; public Dictionary<string, Bitmap>
I have a method with the following signature: public ActionResult RenderFamilyTree(string name, Dictionary<string, string>
I have dictionary, like Dictionary<string, bool> accValues = new Dictionary<string, bool>() And I want
I have written the following code: static readonly object failedTestLock = new object(); public
I have the following functions: public static V AddIfNotPresent<K, V>( this Dictionary<K, V> store,
This is my code: public class MyCollection { internal static Dictionary<string, CheckBox> MyCheckBox =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.