VS hint gives build error



I am trying to remove the little color marks in my Visual Studio code window by applying the VS hints, but these are apparentely impossible because these cause build errors. Here is my code:



using System.Xml.Linq;

XDocument XReport = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
XProcessingInstruction XI = ... ;//ref to xsl stylesheet
XReport.Add(XI);
XReport.Add(...more xml content...);
string NewPageContent = XReport.Declaration.ToString() + XReport.ToString();


This code runs just fine, but VS hints that I should remove the .ToString() twice, then the code builds with an error that you cannot add an XReport.Declaration and an XReport, which makes sense.


Is this a known VS bug?


Any comments on making my code better is also appreciated.


No comments:

Post a Comment