C #: Can I change the build version like this: 1.6?

In Visual Studio, it seems that the version of Assembly may be in the format:

0.0.0.0 

If I changed it to:

 1.6 

And read it in the code, I get 1.6.0.0

Is there a way to change this behavior for a shorter version?

+4
source share
3 answers

Version objects essentially have 4 components, but you can display the short version number in the code by calling the overloaded ToString() method:

 Version v = new Version(1,6,0,0); Console.WriteLine(v.ToString(2)); // prints "1.6" 
+4
source

No. Build options are always 4 numbers. When you extract the code, you always get an instance of System.Version , which has the numbers Major, Minor, Build, Revision.

Of course, you can always set Build and Revision to 0 and only show major and major if you want. If you could describe more of your context (where you use the version number) that would help.

+6
source

No, just because .Net assemblies work just like that when it comes to resolving the correct version.

0
source

All Articles