4

Sometimes we meet some code of VB.net that doesn't support on C#, such as Mid, AscW,Asc, Right, Left .. etc so that i have made the Libraries that made by VBnet. well, my question is simple

is this going to get any problem? if i'm developing with 2 language of NET?

Ricks
  • 277
  • 4
  • 16
  • Going with deadlyDev, no, you won't have any problem. Check this out: http://stackoverflow.com/a/1236196/752527 this process is true for all .net Framework programming languages. – Hanlet Escaño Dec 18 '12 at 08:41
  • 7
    The functionality you mentioned is encapsulated by the `Microsoft.VisualBasic.dll`. Theoretically, you could use this in C# as well. – nikeee Dec 18 '12 at 08:47
  • ok thanks for all answer. nikeee13 : i know they could be used by library Microsoft.VisualBasic.dll. yet, in C# 3.5 the Optional argument doesn't suport in C# function prosedur. replace,instr, etc. they all contain optional argument – Ricks Dec 18 '12 at 09:11
  • 1
    Optional arguments are supported in C# too. This works for me in C# using .NET 3.5: http://pastebin.com/PY9eUVyE – nikeee Dec 18 '12 at 10:14

5 Answers5

2

There's no problem. Just add a reference to Microsoft.VisualBasic and use the functions in your C# code. More discussion of the pros and cons in this question

Community
  • 1
  • 1
MarkJ
  • 30,070
  • 5
  • 68
  • 111
1

You can import .net libraries into any other .net language project. Not a problem.

major-mann
  • 2,602
  • 22
  • 37
1

I think this page (Cross-Language Interoperability) may help you.

Ian Li
  • 910
  • 6
  • 7
0

Alle .net languages can be used with each other - there should be no problem. But I would check VB.net code with "mid" etc. VERY carefully, that are old deprecated VB 6 style functions - there is a huge change that the programmer did not change his programming model as needed.

Christian Sauer
  • 10,351
  • 10
  • 53
  • 85
0

Both those .net languages (all I think) compile to CLI. An intermediate language between machine code and C#/VB.NET.

When you link to a managed DLL it makes no difference what the source language is, the resulting DLL code is the same. Indeed many reflectors (that show a source code representation of a managed DLL's code) have an option to choose the source code language.

Hence, you can link to any managed DLL created from any .net language, using it in any (other) .net language.


If you are only making a library using VB.NET because of functions like Mid, Left, Right etc. you might want to just research the C# equivalents or just code them in C#.

George Duckett
  • 31,770
  • 9
  • 95
  • 162