I was trying to convert some C# code to Vb.net but there was a variable with an asterisk, which apparently VB.net doesn't support. (pointer variables I think they were called, were it refers or something) How would I convert that into VB.net
+2
A:
VB.NET to date does not have any support for pointers or what is generally termaned "unsafe" code in C#. The usual way to do interop with unmanaged code is to make use of the Marshal
class and friends in the Base Class Library. This is slightly more cumbersome to use that simple pointers, and not exactly the same, but it's the only real alternative unless you want to write that bit of your code in C#.
Noldorin
2010-01-13 13:25:36
Of course, if you want any help converting this code to VB.NET using `System.Runtime.InteropServices` and such, you'll need to post the actual code...
Noldorin
2010-01-13 13:28:30
ok I'll just use C#. I was just wondering if I could save my self downloading Visual Studio.
Jonathan
2010-01-13 13:31:58
@Jonathan: Yep, that's probably the easiest solution.
Noldorin
2010-01-13 13:40:48
@Jonathan: if you know VB.NET and don't know C# then you might do better to use Marshal. I've used this in a VB app and it was pretty straightforward.
AAT
2010-01-13 13:49:21
Well I have the code in C# so I only need to compile, which is easier than working out how to use Marshal.
Jonathan
2010-01-13 13:51:01
+1
A:
If the code really has pointers in it, you can't. C# can do unsafe code; VB .NET can't.
One option would be to isolate the code in its own C# project, while doing the rest of the projects in your solution in VB .NET.
Kyralessa
2010-01-13 13:26:58