💻 代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp16
{
internal class Program
{
static void Main(string[] args)
{
Version version01 = new Version("4.0.0.0");
Version version02 = new Version(4,0,0,0);
Version version11 = new Version("4.1.0.0");
if (version01.Equals(version02)) {
Console.WriteLine("version01 == version02");
Console.WriteLine(version01.ToString());
Console.WriteLine(version02.ToString());
}
if (version01 < version11)
{
Console.WriteLine("version01 < version11");
}
string versionString = "1.2.3.4";
Version version;
if (Version.TryParse(versionString, out version))
{
Console.WriteLine("Version parsed successfully.");
Console.WriteLine(version.ToString());
}
else
{
Console.WriteLine("Unable to parse the version string.");
}
//主版本号
Console.WriteLine("Major Version: " + version.Major); // 输出:1
//次版本号
Console.WriteLine("Minor Version: " + version.Minor); // 输出:2
//内部版本号
Console.WriteLine("Build Number: " + version.Build); // 输出:3
//修订号
Console.WriteLine("Revision Number: " + version.Revision); // 输出:4
Console.ReadKey();
}
}
}
📺运行结果