的我得到的未分配的局部變量「字典」儘管我在下面的代碼分配值的誤差用途:使用未分配的局部變量「字典」
private static void UpdateJadProperties(Uri jadUri, Uri jarUri, Uri notifierUri)
{
Dictionary<String, String> dictionary;
try
{
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 => x.Substring(0, x.IndexOf(':') + 2), x => x.Substring(x.IndexOf(':') + 2));
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
try
{
if (dictionary.ContainsKey("MIDlet-Jar-URL: "))
{
// Change the value by Remove follow by Add
}
}
catch (ArgumentNullException ane)
{
throw;
}
}
的錯誤是從線路:
if (dictionary.ContainsKey("MIDlet-Jar-URL: "))
任何人都可以幫我在這裏,請問? TIA
謝謝尼克,傻我! – Chris 2010-06-18 03:43:15