2
我無法確定爲什麼這裏的代碼不能在使用Mono 2.10.6的Win32上的MonoDevelop 2.8.2中編譯。 Monodevelop表明found_image_paths是一個未分配的局部變量?爲什麼這個變量在C#中通過Mono被列爲未分配的局部變量
我失去了一些東西在這裏?我是C新手#
string path = this.DirectoryChooser.CurrentFolder;
Console.WriteLine ("Selected Path: " + path);
//Iterate over all DAE files in this folder
string[] model_paths = Directory.GetFiles(path,"*.dae");
HashSet<string> found_image_paths;
foreach (string dae_path in model_paths)
{
XmlDocument xmlDoc= new XmlDocument(); //* create an xml document object.
xmlDoc.Load(dae_path); //* load the XML document from the specified file.
//* Get elements.
XmlNodeList library_images = xmlDoc.GetElementsByTagName("library_images");
System.Console.WriteLine(dae_path);
foreach (XmlNode image_node in library_images[0].ChildNodes) {
string image_path = image_node.FirstChild.InnerText;
found_image_paths.Add(image_path);
Console.WriteLine(image_path);
}
}
//The next line returns the error "Use of unassigned local variable 'found_image_paths'
foreach (var item in found_image_paths) {
'HashSet found_image_paths = new HashSet ();'似乎工作。 –
JonnyRo