I want to compare the software version created in 3.5 with the older one. If I try to compare version in 4.0 then it's easy by using Version.Parse
but in earlier version this facility is not there. I tried to compare it by using string comparison but still not able get the desired output because string comparison doesn't allow to me compare with minor version or major version. Thanks in advance.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
It seems like you're asking about how to get the versions of any local .NET installations. MSDN has an article about this: http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx.
They include the following function therein:
I ran into a similar problem - I had to parse and sort build numbers so they could be displayed to the user in descending order. I ended up writing my own class to wrap the parts of a build number, and implemented IComparable for sorting. Also ended up overloading the greater than and less than operators, as well as the
Equals
method. I think it has most of the functionality of the Version class, except for MajorRevision and MinorRevision, which I never used.In fact, you could probably rename it to 'Version' and use it exactly like you've done with the 'real' class.
Here's the code:
Forgive me if im missing something but can't you use the version object constructor passing your version string:
http://msdn.microsoft.com/en-us/library/y0hf9t2e%28v=vs.90%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
You could always try to decompile the .NET 4.0 Version class - you might be lucky, that it just works in .NET 3.5.
Otherwise you should look into string split or regular expressions.