0

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

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Jazerix
0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.