在我的控制台应用程序中,我的要求是
I/P:
Version : 10.01
预期的O / P:
Major Version : 10
Minor Version : 01
但返回次要版本:1
Console.Write("Enter the version : ");
var readVersion = Console.ReadLine();
Version version = new Version(readVersion);
Console.WriteLine("Major Version : " + version.Major);
Console.WriteLine("Minor Version : " + version.Minor);
答案 0 :(得分:2)
你可以使用它,
Console.WriteLine("Minor Version : " + version.Minor.ToString("D2"));
而且,
Console.WriteLine("Minor Version : {0:D2}", version.Minor);
希望有所帮助,