开发者

C#: Can I change the Assembly Version to be like this: 1.6?

开发者 https://www.devze.com 2023-01-25 11:35 出处:网络
In Visual Studio it only seems to allow the Assembly Version to be in the format: 0.0.0.0 If I change it to:开发者_JAVA技巧

In Visual Studio it only seems to allow the Assembly Version to be in the format:

0.0.0.0

If I change it to:

开发者_JAVA技巧
1.6

And read it in code I get 1.6.0.0

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


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

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


No. Assembly versions are always 4 numbers. When retrieving in code, you'll 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 display the Major and Minor versions if you want. If you could describe more of your context (where you're using the version number) that would help.


No, simply because this is the way .Net assemblies work when it comes down to resolving the right version.

0

精彩评论

暂无评论...
验证码 换一张
取 消