Sign in to follow this  

I need a hand understanding the structure of Visual Studio .NET programming...

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In university all my programming experience was with C, C++ and Java. The structure (for C) used was that for every codefile there was a header file, and you would include header files to access code in the codefiles. Everything would be compiled by a makefile. So you'd have: main.c main.h include_me.c include_me.h Then in main you would do: #include "include_me.h" That kinda thing... But now I'm programming with Visual Studio .NET, and I'm not sure how things are supposed to work anymore. Specifically, I'm using Visual C#. Are there still header files in C#? Are header files used at all in Visual Studio programming? What is the structure? Right now I have two code files in my C# project. One is a "main" class that runs when the program starts, and the other is a GUI class. The main class is responsible for loading the GUI class. Do I need header files for these classes? When I create them in Visual Studio, the program simply puts all the code in a .CS file instead of in a header. Traditionally I was tought to put the class definition in the header and the function code in the code file. I really wish University would teach this stuff. :-| Thanks.

Share this post


Link to post
Share on other sites
Headers are still used in Visual C++.NET, but not in C#. C# works in a different way - all your files are added to an assembly which generally takes care of all the header stuff that was needed in C++.

It can be odd when you realise that declaration and implementation are in fact now merged into a single file, but it's useful in that you no longer need to maintain two files. C# no longer compiles to native bytecode, instead it's run on the .NET framework CLR which manages many aspects of the code.

Have a look at this Wiki Entry on C#, it's useful for understanding how the language works.

I'm assuming the GUI class you're talking about is the WinForms class? Generally the static Main function (entry point) will launch the WinForms class and enter a (hidden) main loop. You don't have to use WinForms if you don't wish to, but that's the default project type on Visual C# .net.

Remember, if you have the full Visual Studio, you still get C++ (if you install it) so if .NET gets too much you can always revert back it. .NET is strange if you've never worked on it before and can take a bit of getting used to after C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jonny K
Traditionally I was tought to put the class definition in the header and the function code in the code file.


Well headers are best used to put declarations and not definitions all though somethings have to be defined in headers such as inline methods/functions and eventually the operations of a type (but you don't need to define/implement them in headers if there not mean't be inlined. You only wont to include declarations as much as possible.

Quote:
Original post by Jonny K
Right now I have two code files in my C# project. One is a "main" class that runs when the program starts, and the other is a GUI class. The main class is responsible for loading the GUI class. Do I need header files for these classes?


Sounds like another symptom of c++ (traditional) dumb linker syndrome. Although i haven't used C# much it should be the same as java and you don't need headers because of there "smart linkers".

Share this post


Link to post
Share on other sites

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this