on 09-08-2008 4:39 PM
Hi!
I've written an overloaded method with the following signatures:
1.
Public Shared Sub AddCfl( _
ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
ByRef CflEtx As SAPbouiCOM.EditText, _
ByVal CflUidEtx As String, _
ByVal CflAliasEtx As String, _
Optional ByRef CflBtn As SAPbouiCOM.Button = Nothing, _
Optional ByVal CflUidBtn As String = "", _
Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
)
2.
Public Shared Sub AddCfl( _
ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
ByRef CflBtn As SAPbouiCOM.Button, _
ByVal CflUidBtn As String, _
Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
)
3.
Public Shared Sub AddCfl( _
ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
ByRef CflCol As SAPbouiCOM.Column, _
ByVal CflUidCol As String, _
ByVal CflAliasCol As String, _
Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
)
When I try to use the method with first (1.) signature and WITHOUT the optional parameters then I get a very long exception-message: Sth. about "cannot convert into column type".
I guess that .NET is not able to distinguish between signature No 1. and No 3.: Both have the same count of parameters when using No. 1. without the optional param.
But as I understand overloading should also work with the same param.-count as long as the params are of different types, isn't it?
So am I right when saying, that the problem is the COM-Objekt and .NET simply can't distinguish between the types SAPbouiCOM.EditText and SAPbouiCOM.Column?
Thanks for comments!
Roland
Thank you guys for confirming and the tips
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roland,
i also do it like Petr - i create a big method with a switch.
there're some alternative in the web for c# like parameter arrys or create an object for it
but a switch with a single method is the easiest.
lg David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Roland,
I think that you are true. My suggestion is to add in one of method some temp variable with default value which you will not use inside or set CflCol as variant and inside check the type and call the proper method in case, that the is other than you are expecting. Its just idea...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.