我很抱歉这个奇怪的标题,但我无法弄清楚如何表达它:) 我最近转向 C#,目前我正在研究结构。我基本上是一名 C++ 开发人员,在我的 C++ 代码中,我完成了以下操作:
typedef struct
{
String ChannelName;
bool available;
} Voltage_Channel;
Voltage_Channel *m_voltageChannels;
Voltage_Channel redhookChannels[6] = {
{"", false},
{"VDD_IO_AUD", true},
{"VDD_CODEC_AUD",true},
{"VDD_DAL_AUD", true},
{"VDD_DPD_AUD", true},
{"VDD_PLL_AUD", true}
};
if(m_boardName->compareIgnoreCase("S1010012") == 0) //m_BoardName is string
{
m_voltageChannels = redhookChannels;
}
我需要在我的 c# 应用程序中执行此操作。我尝试如下但有问题:
struct VoltageBoardChannel
{
public string ChannelName;
public bool available;
};
VoltageBoardChannel[] mVoltageStruct;
VoltageBoardChannel[] redhookChannels = new VoltageBoardChannel[6]
{
new VoltageBoardChannel() { ChannelName = "", available = false},
new VoltageBoardChannel() { ChannelName = "VDD_IO_AUD", available = true},
new VoltageBoardChannel() { ChannelName = "VDD_CODEC_AUD", available = true},
new VoltageBoardChannel() { ChannelName = "VDD_DAL_AUD", available = true},
new VoltageBoardChannel() { ChannelName = "VDD_DPD_AUD", available = true},
new VoltageBoardChannel() { ChannelName = "VDD_PLL_AUD", available = true}
};
string redhookboardname = "S1010012";
string redhookboardnameCase = "s1010012";
if (redhookboardnameCase.Equals(redhookboardname, stringComparison.InvariantCultureIgnoreCase))
{
mVoltageStruct = redhookChannels;
}
我在哪里犯错???:(