none
How can call vb.net coded function in C#

Answers

  • I'm not sure I understand what you are saying, so I'll take a guess. Is it the optional parameters (strCondition and arr) that are giving the problem? If you are not using Visual Studio 2010, I don't think C# had support for optional parameters. If that is the problem, can you modify the VB code to avoid having Optional parameters (provide overloaded versions of the function both with and without those parameters)? Alternatively, is it possible to avoid calling GetList(Of T) in your code by replacing it in your inheriting class with your own code that accomplishes the same task (I realise that might not be possible or desired)?

    If I didn't guess correctly, could you describe the problem in more detail?

    • Marked as answer by eryang Friday, November 05, 2010 9:11 AM
    Monday, October 25, 2010 3:47 PM

All replies

  • You can only use one language in a project. But you can have multiple projects in different languages as part of a single solution.  So you could include the VB.Net function in a class library and reference that class library from you C# project.

    Another possibility is to translate the VB code into C#. There are several websites that will do the translation for you. One that I have used is http://www.developerfusion.com/tools/convert/vb-to-csharp/

    Monday, October 25, 2010 1:19 PM
  • i tried same way that u mentioned. but the problem is in c#, some parameter of vb.net method did'nt get. i will show u my code

     Public Shared Function GetList(Of T)(ByVal strStoreProcedureName As String, _
                                       ByRef objBeBaseColl As T, _
                                       ByRef objBeBase As BeBase, _
                                       ByVal tableMapping As String(,), _
                                       Optional ByVal strCondition As String = "", _
                                       Optional ByVal arr As Array = Nothing) As T

    i am calling this function to c#, the error is showing that, in third parameter return error,

    'BeBase ' is a base class and that is codded in vb.net. in my c# project that same 'BeBase' class is inheriting

    Thanks

    Monday, October 25, 2010 2:13 PM
  • I'm not sure I understand what you are saying, so I'll take a guess. Is it the optional parameters (strCondition and arr) that are giving the problem? If you are not using Visual Studio 2010, I don't think C# had support for optional parameters. If that is the problem, can you modify the VB code to avoid having Optional parameters (provide overloaded versions of the function both with and without those parameters)? Alternatively, is it possible to avoid calling GetList(Of T) in your code by replacing it in your inheriting class with your own code that accomplishes the same task (I realise that might not be possible or desired)?

    If I didn't guess correctly, could you describe the problem in more detail?

    • Marked as answer by eryang Friday, November 05, 2010 9:11 AM
    Monday, October 25, 2010 3:47 PM
  • Hi,

    Are you saying that the BeBase type parameter is giving the error? Are there 2 different BeBase types defined in both C# and VB.NET projects?


    Please mark the right answer at the right time.
    Thanks,
    Sam
    Tuesday, October 26, 2010 1:54 AM