C#实例应用

代码:

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test07
{
    class Test
    {
        public const double PI = 3.14;
    }
    class Program
    {
        static void Main(string[] args)
        {
            Test test=new Test();//创建类的对象
            Console.WriteLine("常量的值{0}",Test.PI);     //输出常量的值,此处发生错误,常量需要直接使用类名进行调用(与静态成员一样),不能使用使用类的对象调用
            Console.ReadLine();
        }
    }
    
}

运行

相关推荐
014-code4 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024064 小时前
组合模式(Composite Pattern)
开发语言
游乐码4 小时前
c#泛型约束
开发语言·c#
Dontla5 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen5 小时前
python rest请求、requests
开发语言·python
铁东博客5 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui5 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳5 小时前
Python从入门到精通day63
开发语言·python
lbb 小魔仙5 小时前
Python_RAG知识库问答系统实战指南
开发语言·python
hoiii1875 小时前
C# 基于 LumiSoft 实现 SIP 客户端方案
前端·c#