读书人

vb下结构转C#有关问题

发布时间: 2012-01-28 22:06:13 作者: rapoo

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)
在 System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)


在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 Ohyama_Checking_System.Program.Main() 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Ohyama Checking System\Ohyama Checking System\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()

[解决办法]
呵呵………………
这里也开了一贴???
你分还真多!!!

读书人网 >C#

热点推荐