方法与功能 [英] Methods vs functions
本文介绍了方法与功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以解释一下
应该使用word方法或函数之间的区别。它们是否具有相同的含义?
Could someone please explain if there is a difference between when one
should use the word method or function. Do they have the same meaning?
推荐答案
我通常使用术语方法,因为这就是框架如何引用
他们。术语方法在Sub和Function之间没有区别,因此
可以表示Sub或Function。如果你想要明确,那么使用
术语''Sub''或''Function''。另外,在基于C语言的语言中,实际上还有一些其他语言,没有子语言或函数,并创建一个''sub''你
只需设置返回类型为void:
C ++:
void MySub()
{
返回;
}
VB.NET:
Public Sub MySub()
返回
结束子
C ++:
int MyFunc()
{
返回5;
}
VB.NET:
公共功能MyFunc()As Integer
返回5
结束功能
-
HTH,< br $>
- Tom Spink,überGeek
请回复新闻组,
所以所有人都可以受益
" Stefan" < ST ****** @ student.uu.se>在留言中写道
news:u2 ************** @ TK2MSFTNGP11.phx.gbl ...
I generally use the term method, because thats how the framework refers to
them. The term method has no distinction between a Sub and a Function, and
can therefore mean a Sub or a Function. If you want to be explicit, then use
the terms ''Sub'' or ''Function''. Also, in C-based languages, and indeed some
other languages, there are no subs or functions, and to create a ''sub'' you
simply set the return type as void:
C++:
void MySub( )
{
return;
}
VB.NET:
Public Sub MySub()
Return
End Sub
C++:
int MyFunc( )
{
return 5;
}
VB.NET:
Public Function MyFunc() As Integer
Return 5
End Function
--
HTH,
-- Tom Spink, über Geek
Please respond to the newsgroup,
so all can benefit
"Stefan" <st******@student.uu.se> wrote in message
news:u2**************@TK2MSFTNGP11.phx.gbl...
有人可以解释一下当一个人应该使用单词方法或功能时,有区别。它们具有相同的含义吗?
Could someone please explain if there is a difference between when one
should use the word method or function. Do they have the same meaning?
Stefan,
和Tom一样,我使用Sub或Function的方法。
我也会用方法来表示属性程序。
我看待它的方式是:Sub,Function&属性是方法的类型。所以当我想要通用的时候我用
使用方法,当我需要特定的时候使用函数
具体。
希望这有助于
Jay
" Stefan" < ST ****** @ student.uu.se>在留言中写道
news:u2 ************** @ TK2MSFTNGP11.phx.gbl ...
Stefan,
Like Tom I use method for either Sub or Function.
I will also use method to mean Property procedures as well.
The way I view it is: Sub, Function & Property are types of methods. So I
use method when I want to be generic, I use Function when I need to be
specific.
Hope this helps
Jay
"Stefan" <st******@student.uu.se> wrote in message
news:u2**************@TK2MSFTNGP11.phx.gbl...
有人可以解释一下当一个人应该使用单词方法或功能时,有区别。它们具有相同的含义吗?
Could someone please explain if there is a difference between when one
should use the word method or function. Do they have the same meaning?
您好,
Jay B. Harlow [MVP - Outlook]" < JA ******** @ email.msn.com> schrieb:
Hello,
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> schrieb:
和Tom一样,我使用Sub或Function的方法。
这就是我使用术语方法的方式。也是。
我也会使用方法来表示属性程序。
我不会。
我看待它的方式是:Sub,Function&属性是方法的类型。所以当我想要通用时我会使用方法,当我需要特定的时候使用Function。
Like Tom I use method for either Sub or Function.
That''s how I use the term "method" too.
I will also use method to mean Property procedures as well.
I won''t.
The way I view it is: Sub, Function & Property are types of methods. So I
use method when I want to be generic, I use Function when I need to be
specific.
我使用的术语是有点不同(根据
http://msdn.microsoft.com/library/en...gobjects.asp):
" methods"是一个动作,一个对象可以执行。
" properties"属性。
问候,
Herfried K. Wagner
-
MVP·VB Classic,VB .NET
http://www.mvps.org/dotnet
这篇关于方法与功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文