So I need to have a custom type that supported all the standard binary and unary operators.
So VB was immediately out of the picture...made my custom type in C# and did all the operator overloading and did some explicit and implicit conversion functions too.
Everything works great in C# environment...an example of code use:
[CS]
ComplexType c = 4;
c++;
c-= 12;
int i = c;
c += i;
System.Int64 i64 = (System.Int64) c;
c = (ComplexType)--i64;
[/code]
All those lines above work fine in C#...notice the implict casting for Integer and the explicit for Int64.
Now I compile that and open a VB project and import the reference to the DLL.
Now in VB I do:
Heres the error on every line:
Cannot convert from Integer to ComplexType... this shouldnt happen because of my implicit casting. Obviously since this is a value type I cant do DirectCast. I also went back and changed my implicit cast functions to explicit, not thinking it would make a differance...but had to try... and it didnt do anything for me of coarse.
Someone told me to try turning Option Strict off; that didnt change anything; I even tried turn Option Explcit off... same error.
Since I wrote the custom type in C# and compiled it, it shouldnt matter what language it was written in from there right? Its all .NET.
Maybe there is a compile switch or something I dont know about or some sort of attribute, or assembly thing.
Can someone point me in the right direction and tell me what Im doing wrong...and again...everything works perfectly in C#.
So VB was immediately out of the picture...made my custom type in C# and did all the operator overloading and did some explicit and implicit conversion functions too.
Everything works great in C# environment...an example of code use:
[CS]
ComplexType c = 4;
c++;
c-= 12;
int i = c;
c += i;
System.Int64 i64 = (System.Int64) c;
c = (ComplexType)--i64;
[/code]
All those lines above work fine in C#...notice the implict casting for Integer and the explicit for Int64.
Now I compile that and open a VB project and import the reference to the DLL.
Now in VB I do:
Code:
Dim c as ComplexType = 15
c += 5
c = c + 5
c = CType(15, ComplexType)
Cannot convert from Integer to ComplexType... this shouldnt happen because of my implicit casting. Obviously since this is a value type I cant do DirectCast. I also went back and changed my implicit cast functions to explicit, not thinking it would make a differance...but had to try... and it didnt do anything for me of coarse.
Someone told me to try turning Option Strict off; that didnt change anything; I even tried turn Option Explcit off... same error.
Since I wrote the custom type in C# and compiled it, it shouldnt matter what language it was written in from there right? Its all .NET.
Maybe there is a compile switch or something I dont know about or some sort of attribute, or assembly thing.
Can someone point me in the right direction and tell me what Im doing wrong...and again...everything works perfectly in C#.