0

I've been coding a chat program that uses System.Net. I also have a config XML file I put in %appdata%\.ilan, but when I want to declare a new XDocument type variable, Visual Studio Ultimate 2013 doesn't recognize it as a variable, and when I finish the entire variable it says get or set accessor expected. I have made a different program in the same Studio that uses XDocument, and it works there!
I have System.Xml; and System.Xml.Linq; at the top, so I have no idea what's wrong with my code:

public void DefaultXML
{
    XDocument doc = new XDocument(
    new XDeclaration("1.0", "utf-8", "yes"),
    new XComment(" - IlanChat Settings File - "),
    new XElement("settings",
        new XElement("nick", "User")));
}

I have compared it to my previous program and the syntax is the same.

1 Answer 1

5

You forgot to put parentheses after the method name:

public void DefaultXML()   // <--

Without the parentheses, the IDE thinks you're declaring a property instead of a method. That's why it thinks you're missing a get or set accessor.

1
  • Oh dear, I wonder why my IDE hasn't told me.. And @gunr my code is horrible but it works! I'm just a beginner, started learning a month ago :)
    – Ilan
    Nov 7, 2013 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.