Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You problem is that when you defined it: <code>Dictionary&lt;String, String&gt; dictionary;</code> you didn't initialize it. What is happening is that you are assigning a value in a try statement which, depending on what else happens in that statement, may not ever make it to the assignment code of the dictionary variable.<br> You could combine the two try catch blocks. This way you don't need to initialize it, because it is all being used in the same branch of code. There is no way that the dictionary variable can be used before it is assigned.</p> <pre><code>try { Dictionary&lt;string,string&gt; dictionary; String[] jadFileContent; // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader (jadUri.AbsolutePath.ToString())) { Char[] delimiters = { '\r', '\n' }; jadFileContent = sr.ReadToEnd().Split(delimiters, System.StringSplitOptions.RemoveEmptyEntries); } // @@NOTE: Keys contain ": " suffix, values don't! dictionary = jadFileContent.ToDictionary (x =&gt; x.Substring(0, x.IndexOf(':') + 2), x =&gt; x.Substring(x.IndexOf(':') + 2)); if(dictionary == null) { throw new Exception("dictionary is null"); //or ArgumentNullException since you specified //in the second try catch block. } if (dictionary.ContainsKey("MIDlet-Jar-URL: ")) { // Change the value by Remove follow by Add } } catch (ArgumentNullException ane) { throw; } catch (Exception e) { // Let the user know what went wrong. Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload