日期:2014-05-19  浏览次数:20840 次

vb下结构转C#问题
vb下的如下结构在c#如何定义?
Public   Type   CINFTBL
              htid   As   String   *   6
              htdmy   As   String   *   2
              adv   As   Long
              fileno   As   Long
              filesize   As   Long
              jobcmd   As   Long
              datatype   As   Long
End   Type
我这么写,但是会出错
public   struct   CINFTBL
{
public   string[]   htid     ;
public   string[]   htdmy;
public   long   adv;
public   long   fileno;
public   long   filesize;
public   long   jobcmd;
public   long   datatype;
}

再使用的时候先赋值
                                                      string[]   idret=new   string[6]   ;
CINFTBL   inftbl=new   CINFTBL();
for(int   k=0;k <6;k++)
{
idret[k]= "& ";
}
inftbl.htid   =   idret;


请高手指教

------解决方案--------------------
错误出在哪里?

===================
最好是用类来实现....


------解决方案--------------------
用class重写吧
------解决方案--------------------
主要是出现在哪一行呢?
------解决方案--------------------
你的这个问题我也遇到了,也是用VB转C#的问题。我用的是VS2005,运行到hst_open()这个函数出错,提示如下错误:
未处理 System.AccessViolationException
Message= "尝试读取或写入受保护的内存。这通常指示其他内存已损坏。 "
Source= "Ohyama Checking System "
StackTrace:
在 Casio.BarcodeCollectionSeries.hst_open(Int32 chno, INITTBL initab)
在 Casio.BarcodeCollectionSeries.TransmissionData(String path, Int32 model) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Ohyama Checking System\Ohyama Checking System\Casio.cs:行号 180
在 Ohyama_Checking_System.FrmMain.tsmUpload_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Ohyama Checking System\Ohyama Checking System\FormMain.cs:行号 26
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)