Shane Grant
Shane Grant

Reputation: 2654

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

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:

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?

Upvotes: 8

Views: 2118

Answers (3)

Bradley Smith
Bradley Smith

Reputation: 13601

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"

Upvotes: 11

Gerrie Schenck
Gerrie Schenck

Reputation: 22368

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

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500515

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.

Upvotes: 8

Related Questions