【C#】版本号

💻 代码

cs 复制代码
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();
        }
    }
}

📺运行结果

相关推荐
Highcharts.js2 小时前
Highcharts漏斗图表使用配置指南
java·开发语言·javascript·信息可视化·highcharts·漏斗图
ComPDFKit8 小时前
RAG 回答只显示 PDF 文件名?用 Python 保留引用页码
开发语言·python·pdf·rag
FRing038 小时前
vue3干货总结2(vue3生命周期、父子通信、模版引用、provide和inject)
开发语言·前端·vue.js·vue3
琳少_10 小时前
java程序开发笔记
java·开发语言·数据库·笔记
七夜zippoe10 小时前
Agent 告警设计:分级告警、智能降噪与值班排班
开发语言·ai·agent·告警·智能降噪·值班排班
严肃小白兔12 小时前
PHP 8.6 正式发布:部分函数应用、原生 I/O 轮询与新特性实战解析
开发语言·php
郝学胜-神的一滴12 小时前
Effective Python 条款36:优雅拼装迭代器与生成器
开发语言·数据结构·人工智能·python·numpy·scikit-learn
wuyk55514 小时前
Python办公自动化-第04讲-批量新建Excel
开发语言·python·excel
code2cat15 小时前
【随笔】Java客户端选了HTTP/3,怎样知道请求实际走了哪个版本
java·开发语言·http
honker_X17 小时前
Python字符串全攻略:从入门到精通
开发语言·python