Answered by:
can VB & C# to be used in same project?

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
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.
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.
-
-
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.
-
-
-
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
-
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!!!