C# 如何在Initializer.cs C中添加图片# var车辆=新列表 { 新车 { OwnerrName=“Aleks”, RegistrationDate=DateTime.Today, Color=“蓝色”, 车辆类别=“高尔夫”, **?图片?**, Name=“高尔夫” } };

C# 如何在Initializer.cs C中添加图片# var车辆=新列表 { 新车 { OwnerrName=“Aleks”, RegistrationDate=DateTime.Today, Color=“蓝色”, 车辆类别=“高尔夫”, **?图片?**, Name=“高尔夫” } };,c#,C#,我不确定这是否回答了您的问题,如果我得到它,您需要一个图像对象吗?然后,您可以在车辆类中添加图像属性,然后在对象实例化中: var vehicles = new List<Vehicle> { new Vehicle { OwnerrName="Aleks", RegistrationDate=DateTime.Today, Color="blue", VehicleCategory="golf",

我不确定这是否回答了您的问题,如果我得到它,您需要一个
图像
对象吗?然后,您可以在
车辆
类中添加
图像
属性,然后在对象实例化中:

var vehicles = new List<Vehicle>
{
    new Vehicle
    {
        OwnerrName="Aleks",
        RegistrationDate=DateTime.Today,
        Color="blue",
        VehicleCategory="golf",
        **?Picture?**,
        Name="golf"
    }
};
var车辆=新列表
{
新车
{
OwnerrName=“Aleks”,
RegistrationDate=DateTime.Today,
Color=“蓝色”,
车辆类别=“高尔夫”,
ImageObject=Image.FromFile(“img.jpg”),//在这里加载图像
Name=“高尔夫”
}
};

您可以更改图像的路径以找到它

你能提供更多的背景吗?你到底想用这个列表做什么?你应该阅读并问一个合适的问题,否则每个人都会跳到你身上:)。您的代码必须缩进并正确呈现/可测试(Ctrl+K在选择时缩进),并且您应该对您的问题进行很好的解释!
var vehicles = new List<Vehicle>
{
    new Vehicle
    {
        OwnerrName="Aleks",
        RegistrationDate=DateTime.Today,
        Color="blue",
        VehicleCategory="golf",
        ImageObject=Image.FromFile("img.jpg"), //Here you load your image
        Name="golf"
    }
};