Jump to content
  • Advertisement
Sign in to follow this  
coldacid

[.net] Using a C# class with overloaded operators in a VB project

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's the situation. I'm laying out a prototype interface for an alarm clock program (until I have it all ready to redo in C#). I have a backend assembly written in C#, with two classes. One replaces System.DateTime (AlarmClock.ClockTime) so that I don't have to muck about with dates, and the other is to play sound. Pretty much all my logic is in the VB frontend. I've been having a problem, though. It seems that VB.NET doesn't recognize the fact that there are comparison operators in my ClockTime class for comparison to other ClockTime instances and to DateTime instances. The million dollar question then is: Am I doing something wrong so that the overloaded operators don't show, or does VB.NET suck even more than I thought it did?

Share this post


Link to post
Share on other sites
Advertisement
Even when the operator overloading is done in a class written in another CLR supported language? Considering that there are classes in the Microsoft and in the System namespaces with them that work fine with them in VB, I think that I have to have something wrong...

Share this post


Link to post
Share on other sites
He is correct, its not supported.

My question to you is why not just compile the assembly in C#. Then using a reference .... in your vb.net project????

Share this post


Link to post
Share on other sites
Quote:
Original post by coldacid
Considering that there are classes in the Microsoft and in the System namespaces with them that work fine with them in VB

Which classes, if you mind me asking?

Share this post


Link to post
Share on other sites
Quote:
Original post by coldacid
For one, String uses some custom operators.

I think that String is special as it is a 'built-in' value type.

C#
string a = "foo";
string b = "bar";
string c = a + b;

VB.NET
Dim a As String = "foo"
Dim b As String = "foo"
Dim c As String = a & b
Dim d As String = a + b ' same results as c?

Share this post


Link to post
Share on other sites
They all inherit from System.ValueType, perhaps that is the solution?

EDIT1: Well, System.String inherits from System.Object, so that thesis was wrong.

Share this post


Link to post
Share on other sites
Reiterating as said before: VB .Net 2003 doesn't support user defined operators, but it has built in support for a few frameworks types.

2005 will have support for user defined operators.

That said, I believe vb still sees you definitions, but you'll have to invoke them as method calls if you want to use them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!