homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

C# Pointers
how about VB?

 3:27 am on Nov 15, 2005 (gmt 0)

I usually can convert C# to VB no problem, but I've run across some functionality I've never used before. This snippet is part of a image converter that keeps gif transparency. I can't for the life of me figure out how to convert the C# pointers to VB.NET. Would anyone be so kind to flex their conversion muscles? I can get everything but the "byte *" and "*dstp", etc. stuff...

try {
byte *srcp;
byte *dstp;
float m = (float)src.Width / (float)dst.Width;

for (int r = 0; r < dst.Height; ++r) {
dstp = (byte *)dstbd.Scan0;
dstp += dstbd.Stride * r;

for (int c = 0; c < dst.Width; ++c) {
srcp = (byte *)srcbd.Scan0;
srcp += srcbd.Stride * (int)(r * m);
srcp += (int)(c * m);
*dstp++ = *srcp;
finally {



 1:48 pm on Nov 15, 2005 (gmt 0)

matt try kamalpatel.net/ConvertCSharp2VB.aspx


 7:59 pm on Nov 15, 2005 (gmt 0)

That is one of the few things C# can do that VB.NET can't. This is what is called "unsafe" code. It allows you to access memory directly. Done wrongly it can cause GP faults (hence unsafe). VB.NET's philosophy is that you shouldn't be able to do anything unsafe.

In the C# project, there is a setting at the project level that has to be set to allow unsafe code. There is no such setting in VB.NET.

The only solution from VB.NET is to call a DLL that has been written in C#.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved