有趣的VB.NET Intellisense [英] Interesting VB.NET Intellisense

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

问题描述




好​​像VB.NET Intellisense和complier一样检查方法

定义很多。以下代码在VB.NET中编译没有错误! (但是

当然,相信C#要严格和完美:))


[c#]

公共类MyOwnClass

{

public void打印()

{

Console.WriteLine(" Print");

}

}


static void Main(string [] args)

{

object myObj = new MyOwnClass();

myObj.Print();

}


[VB。 NET]

公共类MyOwnClass

公共子打印()

Console.WriteLine(" Print")

结束分

结束课


模块模块1


Sub Main()

Dim myObject As Object = New MyOwnClass

myObject.Print()

End Sub


结束模块


我相信我读过有关VB的动态绑定或

的东西....不知道这是否与它有关。


-

Rakesh Rajan

Hi,

Seems like VB.NET Intellisense and complier does check for method
definitions much. The following code compiles with no errors in VB.NET! (but
of course, trust C# to be strict and perfect :) )

[c#]
public class MyOwnClass
{
public void Print()
{
Console.WriteLine("Print");
}
}

static void Main(string[] args)
{
object myObj = new MyOwnClass();
myObj.Print();
}

[VB.NET]
Public Class MyOwnClass
Public Sub Print()
Console.WriteLine("Print")
End Sub
End Class

Module Module1

Sub Main()
Dim myObject As Object = New MyOwnClass
myObject.Print()
End Sub

End Module

I believe i read somehere about VB being dynamin binding or
something....dunno whether this is something to do with it.

--
Rakesh Rajan

推荐答案

Rakesh,


这是使用VBNet的人在C#中讨厌的事情,它有很多来自C的传统

限制这是必要的,因为它不会在IDE中使用intellisense

,它可以帮助程序员执行,而不是C#是显示更多信息的b $ b(因此是文档管理员)这不是在VBNet中直到2005年的b $ b。


在VBNet中确实是object.whatever。默认表示object.whatever()它是什么呢?
将是经典的C.它可以是什么呢,但它是通过VBNet中的IDE进行的后续编译来检查的,这是一个在VBNet中不存在的功能。

C#。


当你谈论绑定时,比VBNet有两种可能性,

后期绑定和早期绑定。


后期绑定对于建模非常有效,但对于真正的b / b $ b生产软件来说并不好,因为它可能会产生不可预测的错误。很容易在VBNet中设置作为IDE中的一个选项,使用始终选项严格,而不是

它与C#完全相同。


我希望这能给出一些想法'

(当你顺便翻译一种语言时,请不要使用代码的风格

您习惯使用常规代码,VBNet显示的样本将由VBNet程序员制作得更简单。


Cor
Rakesh,

This is something the people who use VBNet do hate in C#, it has many legacy
restrictions from C and that is needed because it does not use intellisense
in the IDE which can help the programmer with the exeption than that C# is
showing some more information (wherefore is the documenter which is not in
VBNet until 2005).

In VBNet does "object.whatever" mean by default "object.whatever()" what it
would be in classic C. What can it be else, however it is checked with
background compiling by the IDE in VBNet, a feature that does not exist in
C#.

When you are talking about binding, than has VBNet two possibilities, with
late binding and early binding.

Late binding can be very effective for modeling however not good for real
production software because it can give unpredicted errors. It is easy to
set in VBNet as a option in the IDE to use always option strict on, and than
it is exactly the same as with C#.

I hope this gives some idea''s

(When you translate a language by the way, do than not use the style of code
you are used to by your regular code, the sample you showed from VBNet would
be made by a VBNet programmer much simpler).

Cor


抱歉......我的意思是看起来像VB.NET Intellisense和编译器不会检查

的方法定义。下面的代码编译没有错误

VB.NET!....错过了一个NOT :)


"


" Rakesh Rajan"写道:
Sorry...i meant "Seems like VB.NET Intellisense and complier does NOT check
for method definitions much. The following code compiles with no errors in
VB.NET!"....missed a NOT :)

"

"Rakesh Rajan" wrote:


似乎像VB.NET Intellisense和编译器确实检查方法定义多。以下代码在VB.NET中编译没有错误! (但是当然,相信C#要严格和完美:))

[c#]
公共类MyOwnClass
{
public void Print( )
{
Console.WriteLine(" Print");
}


static void Main(string [] args)
{
对象myObj = new MyOwnClass();
myObj.Print();
}

[VB.NET]
公共类MyOwnClass
Public Sub Print()
Console.WriteLine(" Print")
End Sub
End Class

模块模块1

> Sub Main()
Dim myObject As Object = New MyOwnClass
myObject.Print()
End Sub

结束模块

我相信我读过关于VB的动态绑定或者什么......不管这是否与它有关。

-
Rakesh Rajan
Hi,

Seems like VB.NET Intellisense and complier does check for method
definitions much. The following code compiles with no errors in VB.NET! (but
of course, trust C# to be strict and perfect :) )

[c#]
public class MyOwnClass
{
public void Print()
{
Console.WriteLine("Print");
}
}

static void Main(string[] args)
{
object myObj = new MyOwnClass();
myObj.Print();
}

[VB.NET]
Public Class MyOwnClass
Public Sub Print()
Console.WriteLine("Print")
End Sub
End Class

Module Module1

Sub Main()
Dim myObject As Object = New MyOwnClass
myObject.Print()
End Sub

End Module

I believe i read somehere about VB being dynamin binding or
something....dunno whether this is something to do with it.

--
Rakesh Rajan



你是VB.NETter吗? ;)
Are you a VB.NETter? ;)
在VBNet中做object.whatever默认表示object.whatever()它在经典C中会是什么。它可以是什么呢,但它是通过VBNet中的IDE进行背景编译来检查的,这是C#中不存在的一个功能。
In VBNet does "object.whatever" mean by default "object.whatever()" what it
would be in classic C. What can it be else, however it is checked with
background compiling by the IDE in VBNet, a feature that does not exist in
C#.



我不明白这个功能是如何有用的 - 这不会导致

错误,这很容易被阻止吗?例如,如果某人在VB.NET中拼错了一个

方法名称 - 这会产生一个运行时异常,而这个

将在C#中被编译@编译时间(好多了。


I don''t understand how this feature could be useful - won''t this result in
errors that could be easily prevented? For example, if someone misspells a
method name in VB.NET - this would create a run-time exception, whereas this
would be caught @ compile time in C# (much better).


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

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