0
Answer

Operator overloading(&) in Assembly written in C# does not work in VB.net Assembly

Gaurave Sehgal

Gaurave Sehgal

15y
2.4k
1
Hi I am trying to overload & operator for a user defined datatype. The assembly is written in C# The code I am writing is as below public static string operator &(object a, UserDefinedType b) { return BitwiseAnd(a,b); } public static string BitwiseAnd(object a, UserDefinedType b) { return string.Format("{0}{1}",a,b); } The code is working fine if I use this from another C# assembly. It stops working if I use it from VB.Net assembly. If I write similar code in VB.net then it works fine with VB.net assembly and stops working with C# assembly. I used reflector and found that VB.net creates op_Concatenate method for it and C# creates op_BitwiseAnd method for it. I tried creating both methods manually in both the assemblies but still it does not work. Is there a way to fix it? Thanks in advance. Gaurave