C#:如何将数据从主文件发送到另一个文件,并将其影响到构造函数参数?

C#:如何将数据从主文件发送到另一个文件,并将其影响到构造函数参数?,c#,C#,我正在使用2个C#.cs文件,第一个文件是主程序.cs,第二个文件用于声明数据和构造函数 我必须将program.cs文件的main函数中的数据发送到另一个.cs文件中声明的名为managevehicle的构造函数,以影响发送到hwManager和dao变量的数据 请问怎么做 这是第二个文件的一部分,我在其中声明变量和构造函数: //Data private HardWareV hwManager; private DaoVehicule dao; //Region Constrcuture

我正在使用2个C#.cs文件,第一个文件是主程序.cs,第二个文件用于声明数据和构造函数

我必须将program.cs文件的main函数中的数据发送到另一个.cs文件中声明的名为
managevehicle
的构造函数,以影响发送到
hwManager
dao
变量的数据

请问怎么做

这是第二个文件的一部分,我在其中声明变量和构造函数:

//Data
private HardWareV hwManager;
private DaoVehicule dao;

//Region Constrcuture

public ManageVehicule(HardWareV hwV, DaoVehicule daoV)
{
    hwManager = hwV;
    dao = daoV;
}

创建
managevehicle
类型的实例,并从
程序中传入所需参数。cs
类似
managevehicle data=newmanagevehicle(new HardWareV(..),new daovhicle(..)
您应该在Program.cs中声明
managevehicle
类,将数据作为参数传递给
managevehicle
构造函数。 e、 g


构造函数意味着“构造”类的实例,因此您应该在
Main
(或某处)中创建类的实例,构造函数将隐式地提供给该实例。
newmanagevehicle(…)
这就是我在Main中所做的:
managevehicle数据=newmanagevehicle(new HardWareV(),new daovhicle())
但它告诉我编译时,
无法为DaoVehicle创建抽象类或接口硬件的实例。
ManageVehicule mv = new ManageVehicule(HwV, DaoV);