I am making an XElement with an element that has LINQ.Binary in it..
The line looks like:
new XElement("Data", binData));
Where binData is of type System.Data.Linq.Binary
what I dont understa开发者_如何学Cnd is that when I look at the xml created it shows
<Data>"mydata"</Data>
instead of
<Data>mydata</Data>
why are there quotes and how do I get rid of them.
The reason you are getting "mydata"
is because that is what the output of System.Data.Linq.Binary
's ToString()
method gives you.
This is a simple way to get rid of them, although plenty of others exist:
string bindatastr = binData.ToString();
new XElement("Data", bindatastr.Substring(1, bindatastr.Length - 2));
精彩评论