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:
Here's the error on every line:
Cannot convert from Integer to ComplexType... this shouldn't happen because of my implicit casting. Obviously since this is a value type I can't 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 didn't do anything for me of coarse.
Someone told me to try turning Option Strict off; that didn't change anything; I even tried turn Option Explcit off... same error.
Since I wrote the custom type in C# and compiled it, it shouldn't matter what language it was written in from there right? It's all .NET.
Maybe there is a compile switch or something I don't know about or some sort of attribute, or assembly thing.
Can someone point me in the right direction and tell me what I'm 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:
Visual Basic:
Dim c as ComplexType = 15
c += 5
c = c + 5
c = CType(15, ComplexType)
Cannot convert from Integer to ComplexType... this shouldn't happen because of my implicit casting. Obviously since this is a value type I can't 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 didn't do anything for me of coarse.
Someone told me to try turning Option Strict off; that didn't change anything; I even tried turn Option Explcit off... same error.
Since I wrote the custom type in C# and compiled it, it shouldn't matter what language it was written in from there right? It's all .NET.
Maybe there is a compile switch or something I don't know about or some sort of attribute, or assembly thing.
Can someone point me in the right direction and tell me what I'm doing wrong...and again...everything works perfectly in C#.