VB.NET和指针 [英] VB.NET and pointers

查看:79
本文介绍了VB.NET和指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB.NET(v2003)不支持指针,对吗?假设这是真的,是否有计划在未来支持指针?请原谅我的无知,但是如果C#支持指针并且C#和VB.NET被编译成相同的代码,那么我不明白为什么VB.NET不能支持指针


感谢您的任何信息

Lance

解决方案

2004-02-07,Lance< zi *** @ hotmail.com>写道:

VB.NET(v2003)不支持指针,对吧?假设这是真的,是否有计划在未来支持指针?请原谅我的无知,但是如果C#支持指针并且C#和VB.NET被编译成相同的代码,那么我不明白为什么VB.NET不能支持指针。

感谢任何信息。
Lance




我用指针假设,你的意思是直接内存寻址 - 就像你一样

可以做在C#中的不安全代码部分。嗯,这不是一个不能支持它的问题。 VB.NET实际上可以支持它,如果设计师认为适合包含它的b $ b,但我不认为会发生这种情况。我认为其中很多

与VB.NET的根源在于BASIC这一事实有关,并且

指针操作不是通常与之关联的人基本:)


指针不是一个神奇的解决方案。在我的9到5中,我是一个C#编码器 - 而我/ b $ b可以告诉你我在

生产代码中从未使用过不安全的代码块。我已经将它们用于我自己的宠物项目(使用Mono的Linux curses库的C#包装器

) - 但即便如此,我也尽量将它们保持在最低限度。当你开始搞乱原始指针时,

你删除了很多托管环境的好处 - 即

自动内存管理和代码安全。


看,如果你需要指针 - 你总是可以在C#

中编写那段代码,然后从VB.NET中调用它。把它当成学习两种语言的好借口(这是我个人的意见,无论如何都要好好学习b $ b)。 />

-

Tom Shelton [MVP]

由Gentoo Linux 1.4提供支持

真相没有什么特别之处它自己的时间。它的时间现在 - 总是。

- Albert Schweitzer


首先,非常感谢您的回复。其余部分主要针对VB.NET的设计者

我用指针假设,你的意思是直接的内存地址在




VB.NET实际上可以支持它如果设计师认为适合包含i


MSDN杂志的最新一期证明了指针的重要性在科学计算方案中(2004年3月,第64页)。我不明白设计师是怎么回事无法预见使用VB.NET的人会遇到这些场景的可能性

我认为很多事情都与VB.NET的根源在于BASIC这一事实有关和指针操作不是通常与BASIC联系的人b $ b

值得庆幸的是,很多VB.NET并不是我通常会与BASIC联系的。这就是为什么我使用VB.NET而不是BASIC :)

当你开始搞乱原始指针时,你会删除托管环境的许多好处 - 即自动内存管理和代码安全


是的,我知道,如果使用不当,指针会导致不良结果。但是,在一些罕见的情况下,没有使用指针的有吸引力的替代方案。此外,程序员有无数种方法可以解决问题。例如,线程呢?这些可能会导致各种问题。所以,不应该是设计师。已经为C#保留了多线程

看看,如果你需要指针 - 你总是可以在C#中编写那段代码,然后从VB.NE中调用它。




这似乎是每个人的建议,就是在他们警告你使用指针的可怕危险之后。那么,C#中的指针在某种程度上比在VB.NET中更安全吗?如果没有,那么允许我使用我最了解的语言中的指针是不是更安全?我想我不遵循指针很危险的逻辑,所以用你不熟悉的语言来使用它们。根据我的经验,使用指针有优势的时候往往是我做一些复杂的事情,这是最糟糕的时间去使用一种不熟悉的语言


我想我很想看到VB.NET中的指针。我只是不认为排除指针,因为真空管日中的一些语言并不支持它们是非常有说服力的。 Leta ??面对它,我们都知道有时候指针是最好的选择。怎么样,如果指针是如此危险,那么将它们放在一个名为System.SmaryPants之类的新命名空间中。或者,Microsoft.VisualBasic.CSharpWantToBe怎么样?这样很明显只有真正有天赋的才能使用它们


Lance




感谢您在社区中发帖。


目前我正在寻找有人看这个问题。我们会尽快给您回复



如果您有任何疑问,请随时在此发布。

谢谢!


祝你好运,

Gary Chang

微软在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有赋予任何权利。

--------------------


VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and VB.NET get compiled into the same code, then I don''t understand why VB.NET can''t support pointers

Thanks for any info
Lance

解决方案

On 2004-02-07, Lance <zi***@hotmail.com> wrote:

VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and VB.NET get compiled into the same code, then I don''t understand why VB.NET can''t support pointers.

Thanks for any info.
Lance



I''m assuming by pointers, you mean direct memory addressing - like you
can do in C# in unsafe code sections. Well, it is not a matter of can''t
support it. VB.NET could in fact support it if the designers saw fit to
include it - but I don''t think that will happen. I think a lot of it
has to do with the fact that VB.NET has it''s roots in BASIC, and
pointer manipulation is not someone usually associates with BASIC :)

Pointers are not a magic solution. In my 9 to 5, I''m a C# coder - and I
can tell you that I have never used an unsafe code block yet in
production code. I have used them for my own pet project (a C# wrapper
for the Linux curses library using Mono) - but even then I try to keep
them to the minimum. When you start messing around with raw pointers,
you remove a lot of the benifits of a managed environment - namely
automatic memory management and code safety.

Look, if you need pointers - you can always write that bit of code in C#
and then call it from VB.NET. Think of it as a good excuse to learn
both languages (it''s my personal oppinion that it is a good idea to
learn both well anyway).

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Truth has no special time of its own. Its hour is now -- always.
-- Albert Schweitzer


First off, thank you very much for your response. The rest of this is directed mostly towards the designers of VB.NET

I''m assuming by pointers, you mean direct memory addressin
Yes
VB.NET could in fact support it if the designers saw fit to include i
The most recent issue of MSDN magazine demonstrated the importance of pointers in scientific computing scenarios (March 2004, pg. 64). I don''t understand how the "designers" can''t foresee the possibility that people who use VB.NET will encounter those scenarios
I think a lot of it has to do with the fact that VB.NET has it''s roots in BASIC, and pointer manipulation is not someone usually associates with BASIC
Thankfully, a lot of VB.NET is not what I would usually associate with BASIC. That''s why I''m using VB.NET rather than BASIC :)
When you start messing around with raw pointers, you remove a lot of the benefits of a managed environment - namely automatic memory management and code safety
Yes, I know, pointers can result in undesirable results if used improperly. But, in some rare situations there are no attractive alternatives to using pointers. Also, there are countless ways for a programmer to get into trouble. For example, what about threads? These can cause all kinds of problems. So, shouldn''t the "designers" have reserved multithreading for C# as well
Look, if you need pointers - you can always write that bit of code in C# and then call it from VB.NE



That seems to be everybody''s recommendation, that is, right after they warn you about the terrible dangers about using pointers. So, are pointers in C# somehow safer than they would be in VB.NET? If not, then wouldn''t it be safer to allow me to use pointers in the language that I''m most knowledgeable? I guess I don''t follow the logic of "pointers are dangerous so go use them in a language that you''re not comfortable with". In my experience, the times when there would be an advantage to using pointers tend to be the times when I''m doing something complex, which is the worst time to go and use an unfamiliar language

I guess it is pretty obvious that I''d like to see pointers in VB.NET. I just don''t think that excluding pointers because some language back in the vacuum-tube-days didn''t support them is very convincing. Leta??s face it, we all know that there are times when pointers are the best option. How about this, if pointers are so dangerous then put them in a new namespace called something like System.SmaryPants. Or, how about Microsoft.VisualBasic.CSharpWantToBe? That way it would be obvious that only the truly gifted should use them

Lance


Hi

Thanks for posting in the community.

Currently I am looking for somebody to look this issue. We will reply you
as soon as possible.
If you have any more concerns on it, please feel free to post here.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------


这篇关于VB.NET和指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆