none
can VB & C# to be used in same project? RRS feed

  • Question

  • we are develop a project

    I'm using C# but my partner are using VB

    is it possible use 2 different language in same project

    if it is possible . can you let me know how?

     

    we have some class and module was written by VB

    is it possible use that when I'm coding ( using C#)

     

    thank you very much

    Monday, January 29, 2007 3:48 AM

Answers

  • Hi,

      you cannot use C# and VB in the same project, but you can use C# projects and VB projects in the same solution.  I would suggest breaking up the work into seperate projects, but ideally you would both use the same language which would make working on eachothers code a lot easier.

     

    Mark.

    Monday, January 29, 2007 3:59 AM

All replies

  • Hi,

      you cannot use C# and VB in the same project, but you can use C# projects and VB projects in the same solution.  I would suggest breaking up the work into seperate projects, but ideally you would both use the same language which would make working on eachothers code a lot easier.

     

    Mark.

    Monday, January 29, 2007 3:59 AM
  • thank you

     

    I just read a reference book. it metion about  "using Visual BASIC"

    if I use this namespace will it work?

    Monday, January 29, 2007 5:55 AM
  • Hi,

      if you mean if you use the VisualBasic namespace in your C# file will that enable you to write VB syntax code, then the answer is still no.  There are some Visual Basic namespaces but those only give you access to the types that are defined in this namespace which may pertain normally to use in VB coding.

     

      You should also be aware of the Common Language Specification (CLS) http://msdn2.microsoft.com/en-us/library/12a7a7h3(VS.80).aspx if you are writing code in both C# and VB.Net.  These are the guidelines for how code should be written so that it can be used by all .Net languages.  For example in C# method naming is case sensative, so you can have "public void foo" and "public void Foo" whereas in VB.Net you cannot.  In this case if you expose these two methods then your class is not CLS compliant.

     

    Mark.

    Monday, January 29, 2007 6:09 AM
  • yes, what you explained is what I want to ask.

    so we have to use same language so it will make ways easy...

     

    ( sad...orz)

    Monday, January 29, 2007 7:08 AM
  • sorry for asking again ( one more question)

     can I use app ( written by VB) when I am coding by C#?

     

    will it work? thanks

    Monday, January 29, 2007 7:11 AM
  • Hi,

      what do you mean by app?  If you create an assembly i.e. DLL or EXE in VB you can use that from a C# project and acess the types and namespaces that have been defined.

     

    Mark.

    • Proposed as answer by Ram_Nalawade Tuesday, January 18, 2011 8:01 AM
    Monday, January 29, 2007 3:10 PM
  • yes! we can use both the languages in same project. For App_Code you have to make two subdirectories .

    E.g. App_Code->CodeforVB

          App_Code->CideforC#

    and add this folder to web.config compile section in code subdirectories option.

    Try this and tell me!!!

     

    Tuesday, January 18, 2011 8:01 AM