dll转换为c#时出现问题

dll转换为c#时出现问题

本文介绍了将vb dll转换为c#时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! vb.code //.BAS文件 类型电台开始作为 长 停止 作为 长 MaxVal 作为 Double end 类型 和以下struct在dll中 typedef struct { long x; byval y; }电台; 当我用c编写代码时 class calldll { [StructLayout(LayoutKind.Sequential)] struct 收音机 { long x; Intptr y; double MaxVal; } // 但是当我尝试使用Mystruct作为类型时,它给出了错误。 类型无线电 { int z; // 错误 - 期望获取或设置访问者 // 再次在这里我需要一些声明参数 } } 我试图将struct更改为类,我也试图删除Type数据类型,它仍然给出了这个错误。 如何在C#中再次使用Radio作为数据类型。 通过将Radio及其变量公开,我可以访问其变量 收音机r = 新收音机 rx = 0; 但我如何在Type Raiod中声明变量vb / .bas文件解决方案 不,你不是尝试MyStruct类型,甚至没有关闭。短语 Type Radio {int z; } 是完全的胡言乱语;我不知道它可能意味着什么,你的想法是什么。 使用类型的东西可能有很多含义。该类型最简单和最重要的用途是创建某种类型的对象,实例化: struct Radio { internal long x; // 否则它将是私有的,无权访问anuwhere // Intptr y; //刮刮了,Intptr未定义 // 此外,我太害怕了想象你会做什么 // 如果是System.IntPtr;你会怎么做? 内部 double MaxVal; } 无线电广播= 新 Radio(); radio.x = 10012 ; // ... 还有静态成员和静态类,OOP,反射,属性......等等。您需要从头开始学习整个编程领域。请参阅.NET和语言手册,祝你好运。祝你好运。 -SA vb.code //.BAS fileType Radio Start As Long Stop As Long MaxVal As Doubleend Typeand following struct is in dlltypedef struct{ long x; byval y;}Radio;when I write code in c# class calldll{ [StructLayout(LayoutKind.Sequential)] struct Radio { long x; Intptr y; double MaxVal ; } // but when i try to use Mystruct as type it gives error. Type Radio { int z; // Error - A get or set accessor expected // again here I have to some declare parameters }}I tried to change struct into class and also i tried to remove Type datatype ,it still gives that error.How I can use Radio as datatype again in C#. By making Radio and its variable public I can access its variable Radio r=new Radio r.x=0;but how can i declare variable in Type Raiod which is done vb/ .bas file 解决方案 No, you are not "trying MyStruct as type", not even close. The phrase Type Radio { int z; } is complete gibberish; I have no idea what it could possibly mean, what was your idea."Using something a type" could have many meanings. The simplest and most important use of the type is creating objects of some type, instantiating it:struct Radio{ internal long x; // otherwise it would be private, with no access to it anuwhere // Intptr y; // scratch is out, Intptr is not defined // besides, I am too terrified to imagine what would you do // if it was System.IntPtr; what would you do with that internal double MaxVal;}Radio radio = new Radio();radio.x = 10012;//...There are also static members and static classes, OOP, reflection, attributes… and a lot more. You need to learn the whole programming field pretty much from scratch. Take some manual on .NET and language and… good luck.—SA 这篇关于将vb dll转换为c#时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 09:48