• Saves Valuable Time
  • Trusted Accuracy for 14 Years
  • 15-Day Money-Back Guarantee

C++ Equivalent to VB Extension Methods

C++ doesn't have extension methods, so a VB extension method is just converted to an ordinary C++ static method (calls to the method have to be adjusted to static calls using the class name).

VB C++
Public Module ContainsExtension
    <System.Runtime.CompilerServices.Extension> _
    Public Sub ExtensionMethod(ByVal myParam As String)
    End Sub
End Module
Friend Class TestClass
    Private Sub TestMethod()
        Dim s As String
    End Sub
End Class
#include <string>

class ContainsExtension final
    static void ExtensionMethod(const std::string &myParam)
class TestClass
    void TestMethod()
        std::string s = "";

Use VB to C++ Converter to convert from VB to C++.     

Additional resource: VB.NET and C++ Equivalents

Copyright © 1997 – 2018 Tangible Software Solutions Inc.