Programming with visual studio
Programming with visual studio
1. vs uses projects and solutions to manage application development.
.a project is a collection of files that produce a .net assembly,such as a library(.dll) or executable (.exe).
.a solution is a collection of projects that are grouped for development or deployment perposes.
2. the xxx solution is stored on disk in a file called xxx.sln.
3. A winform project displays four items:
.Properties – if you expand this item, you will see the assemblyinfo.cs,which contains assembly information for the project;the Resources.resx file,which holds resource information; and the Settings.settings file, which holds projects.
.References- The list of references for the project.These are provided to the compiler using the /reference switch.You can expand this entry to see the default list of assemblies for the project.
.Form1.cs – A file containing the default Form class created for our application. If you expand this entry you will see the Form1.Designer.cs file.
We look at both of these files in a moment.
.Program.cs – The Program class file,which contains the entry point Main.
4. A static class indicates the class cannot be instantiated and contains only static members.
5. The partial keyword declares that this files only contains a portion of the class definition. This keyword allows other files to define additional members of the class. The full class is defined by the set of all partial definitions taken together, so it is an error if two partial definitions conflict with each other.
6. the #region and #endregion directives define a named section of code.
Windows Forms Controls
1. An attribute in C# is a declarative tag that affects the settings or behavior exhibited by an assembly, type(such as a class),or type member(such as a method or property). All attributes are based on the System.Attribute class defined in the .NET Framework as part of the System namespace.
2. The AssembleyVersion attribute: The version number is used internally for comparing expected and actual version numbers of other assemblies used by your application. The format for the version number is a string specified as follows: Major.Minor.Build.Revision
You can use these numbers to mean whatever you wish; these are just recommendations.
3. The build and revision number can be inserted automatically by the compile
Each time an assembly is created. This is done by inserting an asterisk(*) in place of one or both of these numbers.
4. In C++ class variables must be defined before they are used.C#takes a somewhat holistic approach to this issue,allowing a class variable,or field inC#,to be defined before,after,or even in a separate partial file as long as it appears somewhere in the class.
Handling exceptions
1. Exception handling came into existence as a common way to deal with unexpected errors in a program.Since such situations (wrong situations) will certainly occur, a way to recognize such errors is required.
2. Exceptions provide the mechanism for this behavior. They force a programmer to deal with a potential error, or force a program to exit if they are ignored. A forced exit is much safer than continuing to run in an errant state and risk compromising critical data.
3. More formally, an exception is an unexpected error, or exceptional condition, that may occur in a program. Code that creates such a condition is said to throw the exception, and code that processes the condition is said to catch or handle the exception. In .NET, exception are implemented as classes. All .NET exceptions inherit from the System.Exception class, and most not .NET exception are translated into a .NET exception object.
浙公网安备 33010602011771号