您好,我正在尝试保存已创建的对象并将其返回给我错误:“表示为一系列 Unicode 字符”在这一行:System.IO.File.WriteAllLines(@"C:\Users\1\AppData\Roaming\MYDATA\hi.txt", somOne);
这是代码:
主类:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Persone somOne = new Persone("bob", 5, 200);
System.IO.Directory.CreateDirectory(@"C:\Users\1\AppData\Roaming\MYDATA");
// the Error line Is HERE \/
System.IO.File.WriteAllLines(@"C:\Users\1\AppData\Roaming\MYDATA\hi.txt", somOne);
}
}
}
人物类:
namespace ConsoleApplication1
{
class Persone
{
private String name;
private int id;
private int age;
public Persone(String name, int id, int age)
{
setName(name);
setId(id);
setAge(age);
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setId(int id)
{
this.id = id;
}
public int getId()
{
return id;
}
public void setAge(int age)
{
this.age = age;
}
public int getAge()
{
return age;
}
}
}
我需要更改“somOne”的类型吗?如何?