我有一个人的类如下,其中有一个图像作为属性。我正在尝试弄清楚如何在我的程序类中创建person类的实例,并将对象的图像设置为文件路径,例如C:\ Users \ Documents \ picture.jpg。 我该怎么做?
public class Person
{
public string firstName { get; set; }
public string lastName { get; set; }
public Image myImage { get; set; }
public Person()
{
}
public Person(string firstName, string lastName, Image image)
{
this.fName = firstName;
this.lName = lastName;
this.myImage = image;
}
}
myImage
是Image
类型而不是String
,那么你想把文件路径存储在哪里呢?或者你想相应地更改此属性的类型吗? - Tim Schmelter