|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CLS-Compliance and Array Parameter Rankgenerated several warnings telling me about things which weren't quite perfect in my code. I resolved all the warnings except one. I need help with this one. 'Public Function Multiply(A(,) As Double, B() As Double) As Double()' is not CLS-compliant because it overloads 'Public Function Multiply(A(,) As Double, B(,) As Double) As Double(,)' which differs from it only by array of array parameter types or by the rank of the array parameter types. Apparently, my code is not CLS-compliant because B() has the same parameter signature as B(,) under the CLS rules. I understand this problem, but I don't know how to fix it. The only solution I see is to stop overloading (i.e. change the name of one of the two functions), but that will change the public signature of my code. Can anyone suggest a better solution? -TC >The only solution I see is to stop overloading (i.e. change the name of If you don't care about CLS compliance you can apply the>one of the two functions), but that will change the public signature of >my code. Can anyone suggest a better solution? CLSCompliant(False) attribute to the method to get rid of the warning. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Mattias,
Thanks for the advice. Unfortunately, I'm forced to care about CLS compliance. The module in question is referenced by many projects, some of which must be CLS compliant. -TC TC,
What Mattias was suggesting was: <Assembly: CLSCompliant(True)> Public Class Something <CLSCompliant(False)> _ Public Function Multiply(ByVal A(,) As Double, ByVal B() As Double) As Double() Return Nothing End Function Public Function Multiply(ByVal A(,) As Double, ByVal B(,) As Double) As Double(,) Return Nothing End Function End Class You can have the entire assembly CSL compliant, except selected types & methods, as above. NOTE: I don't know why but it makes a difference which one you use <CLSCompliant(False)> on... This is similar to System.Convert.ToUInt32() method. The System.Convert class is CLS Compliant, however the ToUInt32 is not, as UInt32 is not. -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "TC" <golemdan***@yahoo.com> wrote in message news:1148917257.909475.154140@j33g2000cwa.googlegroups.com... | Mattias, | | Thanks for the advice. Unfortunately, I'm forced to care about CLS | compliance. The module in question is referenced by many projects, some | of which must be CLS compliant. | | -TC |
A (not so) basic question.
select case Type Detect if virusscanner is installed Cal Dll was written by VC++ in VB receiving data over socket Obtain contents of an external listview and/or treeview breaking up strings filtering which files can be opened Datagrid scrollbar ¿How can I to get the time of execution of an application? |
|||||||||||||||||||||||