Hey there

This might be a stupid question, but I don't get why i cant do this

string SteamPath;
            XmlDocument LoadDoc = new XmlDocument();
            LoadDoc.Load("Config.xml");
            XmlElement rootless = LoadDoc.DocumentElement;
            if (rootless.Attributes["SteamPath"].Value == "")
            {

            }
            else
            {
                SteamPath = rootless.Attributes["SteamPath"].Value;
            }

            return SteamPath;

It gives me the error "Use of unassigned local variable 'Steam Path'" of course that makes sense, since its under the same code as where its declared, but i just dont get why it has to be like that? How else should i do this?

Sorry if this is a stupid question, i was just wondering why it was like this :)

Cheers
-jaz

Change line 1 to read String SteamPath = String.Empty; You haven't initialised the String and when you try and return it, it is possible that you're trying to return a non-initialised string.

Change line 1 to read String SteamPath = String.Empty; You haven't initialised the String and when you try and return it, it is possible that you're trying to return a non-initialised string.

ohhhh, makes sense, thanks! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.