tags:

views:

95

answers:

3

I am new to SO and also to the C# language. I browsed for a bit and was not able to find anything relating to this subject. I program in other languages, mainly C and C++. When I want to show someone my code I show them the .c or .cpp files and any header files I have created.

However, if I want to show the source code to a program in C# what do I use? It is especially confusing when I create a new WindowsFormApplicaiton

A: 

You can use notepad (open the .cs file) or visual studio. If you don't have a pro copy you can use one of the express editions of visual studio. When in VS you can right click on the form and select View Code. I hope my response is on track with your question!

Andrew Siemer
+1  A: 

When you create a Winforms application, you get two .cs files: Program.cs and Form1.cs. When you are looking at the form, you can right-click on it and choose View Code. This is called a "code behind", and is where the implementation of the form lives.

Bill Wert
+3  A: 

Technically all you need is the .cs files, but to make it easy on the person receiving this (and assuming you are using Visual Studio) just take the entire Visual Studio project directory (should include a .sln file, one or more .csproj files, all the .cs files, and any other assets) and zip/rar it.

The user on the receiving end can unzip the whole structure and double-click the .sln file, and they will get the same view in Visual Studio that you had.

A little more detail:

Forms are still just c# (.cs text) files.

The .csproj is an XML file that contains pointers to all your .cs files, as well as some project metadata.

The .sln file is an XML file that contains pointers to all your .csproj files, as well as some metadata about source control, project relationships, etc.

Rex M