Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

C# Equivalent to C++ Operator Overloading

C# operator overloading is similar to C++ operator overloading, except that C# operator overloads are static methods while C++ operator overloads are instance methods. During conversion by C++ to C# Converter, references to 'this' within the method are converted to the added first parameter.

C++:

class SomeType
{
private:
   int IntValue = 0;

public:
   int operator + (const SomeType &Y)
   {
      return this->IntValue + Y.IntValue;
   }
};

C#:

public class SomeType
{
   private int IntValue;

   public static int operator +(SomeType X, SomeType Y)
   {
      return X.IntValue + Y.IntValue;
   }
}

If you need to convert from C++ to C# and you are depending on the results being reliable and accurate, then you will want to have C++ to C# Converter, the best C++ to C# converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.