visual studio.NET中的接口和重载函数 [英] Interface and overloaded functions in visual studio.NET

查看:95
本文介绍了visual studio.NET中的接口和重载函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有这个界面:


Public Interface MyInterface

函数test()As Boolean

函数测试(ByVal MyVar As String)作为布尔值

结束界面


然后我做一个


Public Class MyOwnClass

实现MyInterface

结束类


当我在实现MyInterface后点击[Enter]

Visual Studio自动创建


公共重载函数test()As Boolean实现MyInterface.test

结束函数


公共过载函数test1(ByVal MyVar As String)作为布尔值

实现MyInterface.test

结束函数


这两个函数适合我。 ..


为什么在重载的函数名称上添加1?

为什么它不只是进行测试()和测试(ByVal Myvar作为字符串)

函数?

这种行为是否有特定原因?
解决方案

" sotto" <菊** @ sotto.invalid> schrieb

如果我有这个接口:

Public Interface MyInterface
Function test()As Boolean
函数测试(ByVal MyVar As String)As Boolean
结束界面

然后我做了一个

公共类MyOwnClass
实现MyInterface
结束类

当我在实现MyInterface后按[Enter]
Visual Studio自动创建

公共重载函数test()As布尔实现
MyInterface.test结束函数
实现MyInterface.test
结束函数

这两个函数对我来说......

为什么它在重载的函数名称上添加1?
为什么它不只是进行测试()和测试(ByVal Myvar为字符串)
函数?
这种行为有特定原因吗?




如果你已经有了这个行为使用名称为test的ocedure,IDE使用这种

类型的编号。在这种情况下,它没有必要,所以你是对的。

我会在microsoft.public.vsnet.ide中再次发布它。

-

Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


* sotto< ju **@sotto.invalid> scripsit:

如果我有这个界面:

公共接口MyInterface
函数test()作为布尔值
函数测试(ByVal MyVar As String)As Boolean
结束界面

然后我制作一个公共类MyOwnClass
实现MyInterface
结束类
当我在实现MyInterface后按[Enter]
Visual Studio自动创建

公共重载函数test()As Boolean实现MyInterface.test
结束函数

公共重载函数test1(ByVal MyVar As String)作为Boolean
实现MyInterface.test

结束函数

这两个函数对我来说......

为什么在重载的函数名称上添加1?
为什么它不只是进行测试()和测试(ByVal Myvar As string)
函数?

这种行为有特定的原因吗?




我目前不喜欢这里没有VS.NET 2003,但是如果它在名称末尾用1

命名它可能是一个bug。


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>


>我目前在这里没有VS.NET 2003,但如果它

用1命名它。在名称的末尾它可能是一个错误。


我使用的是VS2003,并且它使用数字

后缀来命名重载的接口方法。


例如


测试()

测试1()

测试2()





Trev。

" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:ez ************* @ TK2MSFTNGP10.phx.gbl ... * sotto< ju ** @ sotto.invalid> scripsit:

如果我有这个界面:

公共接口MyInterface
函数test()作为布尔值
函数测试(ByVal MyVar As String)As Boolean
结束界面

然后我制作一个公共类MyOwnClass
实现MyInterface
结束类
当我在实现MyInterface后按[Enter]
Visual Studio自动创建

公共重载函数test()As Boolean实现MyInterface.test
结束函数

公共重载函数test1(ByVal MyVar As String)作为Boolean
实现MyInterface.test

结束函数

这两个函数对我来说......

为什么在重载的函数名称上添加1?
为什么它不只是进行测试()和测试(ByVal Myvar As string)
函数?

这种行为有特定的原因吗?



我目前还没有ave VS.NET 2003在这里,但是如果它在名称的末尾用1命名它可能是一个bug。

-
Herfried K 。瓦格纳[MVP]
< http://www.mvps.org/dotnet>



If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test
End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn''t it just make a test() and a test(ByVal Myvar As string)
function?
Is there a specific reason for this behaviour?

解决方案

"sotto" <ju**@sotto.invalid> schrieb

If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements
MyInterface.test End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test
End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn''t it just make a test() and a test(ByVal Myvar As string)
function?
Is there a specific reason for this behaviour?



If you''ve already got a procedure with the name "test", the IDE uses this
kind of numbering. In this case, it wouldn''t be necessary, so you''re right.
I''d post it again in microsoft.public.vsnet.ide.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


* sotto <ju**@sotto.invalid> scripsit:

If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test

End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn''t it just make a test() and a test(ByVal Myvar As string)
function?

Is there a specific reason for this behaviour?



I currently don''t have VS.NET 2003 here, but if it names it with an "1"
at the end of the name it is maybe a bug.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


> I currently don''t have VS.NET 2003 here, but if it

names it with an "1" at the end of the name it is maybe a bug.
I use VS2003 and it does name overloaded interface methods with an number
suffix.

e.g.

Test()
Test1()
Test2()

etc.

Trev.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ez*************@TK2MSFTNGP10.phx.gbl... * sotto <ju**@sotto.invalid> scripsit:

If i have this Interface:

Public Interface MyInterface
Function test() As Boolean
Function test(ByVal MyVar As String) As Boolean
End Interface

And then i make a

Public Class MyOwnClass
Implements MyInterface
End Class

When i hit [Enter] after the Implements MyInterface
Visual Studio automatically creates

Public Overloads Function test() As Boolean Implements MyInterface.test
End Function

Public Overloads Function test1(ByVal MyVar As String) As Boolean
Implements MyInterface.test

End Function

These two functions for me...

Why does it add the 1 on the overloaded function-name?
Why doesn''t it just make a test() and a test(ByVal Myvar As string)
function?

Is there a specific reason for this behaviour?



I currently don''t have VS.NET 2003 here, but if it names it with an "1"
at the end of the name it is maybe a bug.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>



这篇关于visual studio.NET中的接口和重载函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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