我在XmlWriter中遇到了Create方法的问题.
即使我使用msdn中的示例,它也无法正常工作. http://msdn.microsoft.com/en-us/library/kcsse48t.aspx
我为Windows商店应用创建了一个"空白页面"项目.在其中,我插入了来自msdn的示例代码,以测试XmlWriter类的工作方式.
VS给了我错误:
Cannot resolve method 'Create(string)', candidates are:
System.Xml.XmlWriter Create(System.IO.Stream) (in class XmlWriter)
System.Xml.XmlWriter Create(System.IO.TextWriter) (in class XmlWriter)
System.Xml.XmlWriter Create(System.Text.StringBuilder) (in class XmlWriter)
System.Xml.XmlWriter Create(System.Xml.XmlWriter) (in class XmlWriter)
Run Code Online (Sandbox Code Playgroud)
这在控制台应用程序中没有问题.但我需要制作一个Windows应用商店.
我希望最终做的是添加到现有的xml文件.
有人可以告诉我为什么这不起作用,或者如何以不同的方式达到我的目标.
感谢您的时间.
编辑:
对不起,我的代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Xml;
using System.Xml.Linq;
using Windows.Data.Xml.Dom;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at …Run Code Online (Sandbox Code Playgroud) 你好,谢谢你的时间.
我最近决定尝试使用Xamarin.Android来开发我的想法.
但是,我遇到了我曾经遇到过的最棘手的问题.
public class Note : INote
{
public string Content { get; set; }
public DateTime DateTime { get; set; }
public List<ITag> Tags { get; set; }
public override string ToString()
{
try
{
const int maxLength = 20;
if (Content.Length > maxLength)
{
return Content.Substring(0, maxLength - 1);
}
return Content;
}
catch (Exception)
{
return Content;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的类中,当我对一个小于20个字符的音符对象进行ToString操作时,我得到一个未处理的异常.我认为这很奇怪,所以我在try/catch中用子串包装了部分.
但是,我仍然得到一个未处理的例外.怎么会这样?
填充ListView时会调用ToString,这是在这段代码中完成的.
[Activity(Label = "@string/ApplicationName")]
public class ShowNotesActivity : Activity
{
protected override void …Run Code Online (Sandbox Code Playgroud)