|
Subject:
|
C# coding style
|
|
Posted By:
|
csharplearner
|
Post Date:
|
4/22/2005 7:24:44 PM
|
Hi all,
I have recently moved from C++ to C#. I have seen lot of difference in the coding style of C++ and C#. I am little confused and here are some of questions.
1. What is the equivalent of C++ header file in C#?
2. I am taught in school that all the function prototypes go in header file; the implementations or the methods go into the implementation file (CPP file) and the main function goes into another CPP file and while running the program, you compile, link and execute the program.....So is it not the same in C#? I have seen textbooks just writing the methods and functions within a class in one single file and there is no function prototype....Please Clarify.
Thanks in advance, Csharplearner
|
|
Reply By:
|
Doknjas
|
Reply Date:
|
4/22/2005 8:54:10 PM
|
Separate declaration and implementations are obsolete in modern programming environments. The signature of methods are very easy to view separately in any modern environment, so why specify them separately? C++ had its time, but that time was long ago.
|
|
Reply By:
|
planoie
|
Reply Date:
|
4/23/2005 4:17:09 PM
|
All .NET code in any .NET language can see all public classes that live in the set of files that are compiled together. In Visual Studio.NET you group the files together in a project. VS compiles all those files into a single assembly. In command-line compiling, you have to specify all the files you want compiled to the assembly.
You can reference other assemblies so your code can use classes that live in those other assemblies. When the compiler compiles your code, it will look in all referenced assemblies for classes that you consume in your code. In command-line compiling you must compile each assembly in the necessary order so that you have all the dependant assemblies compiled first. In a VS.NET project, you set up project references to the other projects you'll be using. VS will automatically determine the compile order to satisfy the dependancy requirements.
-Peter
|
|
Reply By:
|
chinanetwork
|
Reply Date:
|
4/25/2005 12:59:04 AM
|
hi all First i say some other thing . my english is very poor---i am a chinese.i have learnt Prammgring 2 year .use c#.above quession i thing i can not answer because i never use c++ before .if you want to make a learnt friend with me ,Please use msn:goodbtob@hotmail.com. welcome! how poor my english is ! haha!
|
|
Reply By:
|
csharplearner
|
Reply Date:
|
4/26/2005 1:01:25 PM
|
Thank you Peter,Doknjas and chinanetwork
|
|
Reply By:
|
aehb
|
Reply Date:
|
4/27/2005 3:16:09 PM
|
hello, the equivalent of header files of C++ is the "Assemblies" in C#. no need to split your code to header files and implementation files here. and also the execution of the code starts at the function "Main".
|