The version number and subversion number of a C# assembly are part of the assembly and are used to identify different versions of the assembly. Version number usually consists of four parts: the primary version number, the secondary version number, the generation number and the revision number. Among them, the main version number and the minor version number are the two most commonly used parts.
Major Version:
Indicates a significant update or feature improvement to the assembly. When major structural changes are made or new incompatible features are introduced, the main version number is incremented.
Minor Version:
Indicates a small update or fix for the assembly. The subversion number will increment when some minor feature improvements or fixes some errors.
The format of the version number is usually "main version number. minor version number. generation number. revision number", for example: 1.2.3.4. Among them, the generation number and the revision number are optional, which represent the number of builds and revisions of the assembly.
In C#, you can get the version number and subversion number of the assembly by accessing the AssemblyName object of the assembly.
Here is a sample code:
using System; using ; class Program { static void Main() { Assembly assembly = (); AssemblyName assemblyName = (); Version version = ; int majorVersion = ; int minorVersion = ; ("Main Version Number: " + majorVersion); ("Second version number: " + minorVersion); } }
In the above code, we use the () method to get the object of the current assembly, and then use the AssemblyGetName() method to get the object. Finally, we can get the version number through the AssemblyNameVersion property and use the Major and Minor properties to get the major and minor version numbers.
This is the article about the implementation of the main version number and secondary version number of C# assembly. For more information about the main version number and secondary version number of C# assembly, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!