"Newbie" <not@not.not> wrote in news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl:
[color=blue]
> Does VB.NET allow use os pointers like in C++??
>
> example:
>
> int* i = &f;[/color]
There are no pointers in VB.NET, but you can assign a variable to hold a
reference to an object.
But I think if you really need to use pointers, you can call non-managed
Win32 commands.
If I may ask, what do you need pointers for? I've only found one need for
pointers in VB.NET - to speed up moving Bitmaps around in memory quickly,
and was able to work around that using Marshal.WriteBy te(), etc. to get the
job done. Are you just trying to convert some code from C#/C++ or do you
have an actual problem that requires pointers?
Thanks
"Newbie" <not@not.not> wrote in message
news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=blue]
> Does VB.NET allow use os pointers like in C++??
>
> example:
>
> int* i = &f;
>
> how would this line of code be in vb.net?
>
> thanks!
>
>[/color]
I'm a bit confused because of these pointers... I think I'll just give up
and use the C++ code.
thanks for the helps!
"Michael C#" <xyz@abcdef.com > wrote in message
news:PjOse.1468 9$l_2.13659@fe0 9.lga...[color=blue]
> If I may ask, what do you need pointers for? I've only found one need for
> pointers in VB.NET - to speed up moving Bitmaps around in memory quickly,
> and was able to work around that using Marshal.WriteBy te(), etc. to get
> the job done. Are you just trying to convert some code from C#/C++ or do
> you have an actual problem that requires pointers?
>
> Thanks
>
> "Newbie" <not@not.not> wrote in message
> news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=green]
>> Does VB.NET allow use os pointers like in C++??
>>
>> example:
>>
>> int* i = &f;
>>
>> how would this line of code be in vb.net?
>>
>> thanks!
>>
>>[/color]
>
>[/color]
"Michael C#" <xyz@abcdef.com > wrote in message
news:PjOse.1468 9$l_2.13659@fe0 9.lga...[color=blue]
> If I may ask, what do you need pointers for? I've only found one need for
> pointers in VB.NET - to speed up moving Bitmaps around in memory quickly,
> and was able to work around that using Marshal.WriteBy te(), etc. to get
> the job done. Are you just trying to convert some code from C#/C++ or do
> you have an actual problem that requires pointers?
>
> Thanks
>
> "Newbie" <not@not.not> wrote in message
> news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=green]
>> Does VB.NET allow use os pointers like in C++??
>>
>> example:
>>
>> int* i = &f;
>>
>> how would this line of code be in vb.net?
>>
>> thanks!
>>
>>[/color]
>
>[/color]
As Michael wrote would you first have to look where you need those pointers
for. What you do is in my opinion not converting this is recoding. Because
as you do it now, you get in my opinion the worst things from both sides.
One sample, nobody can maintain than your program because it is done in a
way, that nobody understand.
If you after those answers still want to create a bad program. Have than a
look at delegates in VBNet.
"Newbie" <not@not.not> wrote in
news:#7TuCs8cFH A.3492@TK2MSFTN GP14.phx.gbl:[color=blue]
> does C# has pointers?[/color]
Not really. .NET doesnt have pointers per se. You can simulate them, or in some cases use
unmanaged code, but in effect .NET does not have pointers, and I for one am glad to see them
finally gone. Pointers have no place in business code.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
"Chad Z. Hower aka Kudzu" <cpub@hower.org > schrieb:[color=blue][color=green]
>> does C# has pointers?[/color]
>
> Not really. .NET doesnt have pointers per se. You can simulate them, or in
> some cases use
> unmanaged code, but in effect .NET does not have pointers, and I for one
> am glad to see them
> finally gone. Pointers have no place in business code.[/color]
C# actually supports pointers. However, you must place the code in an
'unsafe' block.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in
news:OlW2sv#cFH A.2696@TK2MSFTN GP09.phx.gbl:[color=blue][color=green]
>> or in some cases use
>> unmanaged code, but in effect .NET does not have pointers, and I for[/color]
>
> C# actually supports pointers. However, you must place the code in an
> 'unsafe' block.[/color]
Yes I mentioned in unmanaged, I should have added unsafe as well.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
Develop ASP.NET applications easier and in less time:
If you REALLY want to get a pointer to a variable, you can copy it to
unmanaged memory with Marshal class, and get a pointer to this copy:
Dim i As IntPtr
i = Marshal.AllocHG lobal(Marshal.S izeOf(f))
Marshal.Structu reToPtr(f, i, True)
REM Do whatever you want
f = CType(Marshal.P trToStructure(i , f.GetType()), Integer)
Marshal.FreeHGl obal(i)
It's very complicated, but I can't find another way.
"Newbie" <not@not.not> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=blue]
> Does VB.NET allow use os pointers like in C++??
>
> example:
>
> int* i = &f;
>
> how would this line of code be in vb.net?
>
> thanks!
>
>[/color]
As I said, there are ways to work around the lack of pointers; but I've
found very few situations where code using pointers couldn't be rewritten
avoiding pointers completely. The only value I see in using pointers is for
large memory move or memory update operations, such as graphics subroutines,
where the standard managed interfaces are just way too slow. For those you
can use the Marshal class methods to get better performance.
Thanks
"Newbie" <not@not.not> wrote in message
news:OZ1mwr8cFH A.3616@TK2MSFTN GP09.phx.gbl...[color=blue]
> I'm trying to convert a C++ code to VB.NET....
>
> I'm a bit confused because of these pointers... I think I'll just give up
> and use the C++ code.
>
> thanks for the helps!
>
>
> "Michael C#" <xyz@abcdef.com > wrote in message
> news:PjOse.1468 9$l_2.13659@fe0 9.lga...[color=green]
>> If I may ask, what do you need pointers for? I've only found one need
>> for pointers in VB.NET - to speed up moving Bitmaps around in memory
>> quickly, and was able to work around that using Marshal.WriteBy te(), etc.
>> to get the job done. Are you just trying to convert some code from
>> C#/C++ or do you have an actual problem that requires pointers?
>>
>> Thanks
>>
>> "Newbie" <not@not.not> wrote in message
>> news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=darkred]
>>> Does VB.NET allow use os pointers like in C++??
>>>
>>> example:
>>>
>>> int* i = &f;
>>>
>>> how would this line of code be in vb.net?
>>>
>>> thanks!
>>>
>>>[/color]
>>
>>[/color]
>
>[/color]
"Dragon" <no@spam.please > wrote in message news:d914u5$ddd $1@news.rol.ru. ..[color=blue]
> If you REALLY want to get a pointer to a variable, you can copy it to
> unmanaged memory with Marshal class, and get a pointer to this copy:
> Dim i As IntPtr
>
> i = Marshal.AllocHG lobal(Marshal.S izeOf(f))
>
> Marshal.Structu reToPtr(f, i, True)
>
> REM Do whatever you want
>
> f = CType(Marshal.P trToStructure(i , f.GetType()), Integer)
>
> Marshal.FreeHGl obal(i)
>
> It's very complicated, but I can't find another way.
>
> "Newbie" <not@not.not> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
> news:uAuIqz7cFH A.2124@TK2MSFTN GP14.phx.gbl...[color=green]
>> Does VB.NET allow use os pointers like in C++??
>>
>> example:
>>
>> int* i = &f;
>>
>> how would this line of code be in vb.net?
>>
>> thanks!
>>
>>[/color]
>
>
>[/color]
Comment