来电者类型? [英] Caller Type ?
问题描述
大家好...
首先抱歉我的英语不好。
查看下一个代码
Dim oDS as Dataset' '< =来电者
oDs = MyFunc
''其他来电者类型
Dim i as integer = MyFunc
public MyFunc(....)作为对象
问题:如何检测方法中的调用者类型?
因为我需要铸造返回值。
如果???是GetType(DataSet)然后
返回CType(ret as DataSet)
否则如果
bla bla bla ...
结束功能
问候
Genival Carvalho
Hello all...
First sorry my bad English.
Look next code
Dim oDS as Dataset '' <= Caller
oDs = MyFunc
''other caller type
Dim i as integer = MyFunc
public MyFunc(....) as object
Question : How do to detect caller type inside a method ?
Because i need return value casted.
if ??? is GetType(DataSet) then
return CType(ret as DataSet)
else if
bla bla bla...
End Func
Regards
Genival Carvalho
推荐答案
> ;问题:如何检测方法中的来电类型?
简短的回答是你不能。
你可以使用重载函数和ByRef参数来返回
结果。
Sub MyFunc(ByRef ds As Dataset)
Sub MyFunc(ByRef i As Integer)
....
Dim oDS As Dataset
MyFunc(oDS )
或者您可以遵循某些框架类使用的模式,并且
为每种可能的返回类型使用单独的方法
函数MyFuncDataset()作为数据集
函数MyFuncInt32()作为数据集
Mattias
- -
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
请仅回复新闻组。
>Question : How do to detect caller type inside a method ?
The short answer is that you can''t.
You could use overloaded functions and a ByRef parameter to return the
result instead.
Sub MyFunc(ByRef ds As Dataset)
Sub MyFunc(ByRef i As Integer)
....
Dim oDS As Dataset
MyFunc(oDS)
Or you could follow the pattern used by some framework classes, and
use separate methods for each possible return type
Function MyFuncDataset() As Dataset
Function MyFuncInt32() As Dataset
Mattias
--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
" Genival" < GE ***** @ hotmail.com> schrieb
"Genival" <ge*****@hotmail.com> schrieb
大家好......
首先抱歉我的英语不好。
看下一个代码
Dim oDS as Dataset''< = Caller
oDs = MyFunc
''其他来电者类型
Dim i as integer = MyFunc
公共MyFunc(....)作为对象
问题:如何检测方法中的调用者类型?
因为我需要返回值铸造。
如果???是GetType(DataSet)然后
返回CType(ret为DataSet)
如果
bla bla bla ...
End Func
Hello all...
First sorry my bad English.
Look next code
Dim oDS as Dataset '' <= Caller
oDs = MyFunc
''other caller type
Dim i as integer = MyFunc
public MyFunc(....) as object
Question : How do to detect caller type inside a method ?
Because i need return value casted.
if ??? is GetType(DataSet) then
return CType(ret as DataSet)
else if
bla bla bla...
End Func
你不应该关心来电者。写两个功能。一个功能
返回一种类型,另一种函数返回不同的类型。
-
Armin
You should not care about the caller. Write two functions. One function
returns one type, the other function returns a different type.
--
Armin
但是......
Inside ConvertTo我有这个:
InstanceDescriptor
我不能在我的功能中使用此功能?
问候
Genival Carvalho
" Genival" < GE ***** @ hotmail.com> escreveu na mensagem
新闻:es ************* @ TK2MSFTNGP09.phx.gbl ...
But...
Inside ConvertTo i have this :
InstanceDescriptor
I can''t use this feature inside my func ?
Regards
Genival Carvalho
"Genival" <ge*****@hotmail.com> escreveu na mensagem
news:es*************@TK2MSFTNGP09.phx.gbl...
大家好......
首先抱歉我的英语不好。
看下一个代码
Dim oDS as Dataset''< = Caller
oDs = MyFunc
' '其他来电类型
Dim i as integer = MyFunc
公共MyFunc(....)作为对象
问题:如何检测一个内部的调用者类型方法?
因为我需要返回值铸造。
如果???是GetType(DataSet)然后
返回CType(ret为DataSet)
如果
bla bla bla ...
End Func
问候
Genival Carvalho
Hello all...
First sorry my bad English.
Look next code
Dim oDS as Dataset '' <= Caller
oDs = MyFunc
''other caller type
Dim i as integer = MyFunc
public MyFunc(....) as object
Question : How do to detect caller type inside a method ?
Because i need return value casted.
if ??? is GetType(DataSet) then
return CType(ret as DataSet)
else if
bla bla bla...
End Func
Regards
Genival Carvalho
这篇关于来电者类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!