惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
美团技术团队
量子位
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
Apple Machine Learning Research
Apple Machine Learning Research
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Announcements
Recent Announcements
Cisco Talos Blog
Cisco Talos Blog
L
LangChain Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 三生石上(FineUI控件)
U
Unit 42
T
Tenable Blog
Security Latest
Security Latest
Scott Helme
Scott Helme
B
Blog
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
A
Arctic Wolf
S
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
雷峰网
雷峰网
The Cloudflare Blog
Cloudbric
Cloudbric
Latest news
Latest news
Project Zero
Project Zero
S
Secure Thoughts
V
Visual Studio Blog
博客园 - Franky
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity

博客园 - newbin

<该停暖气了> stay hungry,stay foolish Stay hungry, Stay foolish... string与stringbuilder的区别 为了实现自我价值,加油,加油! 多态和继承(Inheritance) abstract和interface的异同 [转贴]一名大学生应聘软件工程师的经历和感受 c# brief datagrid,datalist,repeater在Html页中的定义 系统默认提供的CSS样式风格定义 thanks giving 真不知道怎么过 找根火柴棍把眼皮支起来 软件开发的四项基本原则 我们为什么需要 XML Windows 2000的引导过程 Understand CSS Terminology ROUNDTRIP AND POSTBACK 生命如此年轻
关于const的一些解释
newbin · 2004-11-30 · via 博客园 - newbin

const 关键字用于修改字段或局部变量的声明。它指定字段或局部变量的值不能被修改。常数声明引入给定类型的一个或多个常数。

备注

常数声明可以声明多个常数,例如:

public const double x = 1.0, y = 2.0, z = 3.0;

不允许在常数声明中使用 static 修饰符。

常数可以参与常数表达式,例如:

public const int c1 = 5.0;
public const int c2 = c1 + 100;

示例

// const_keyword.cs
// Constants
using System;
public class ConstTest 
{
   class MyClass 
   {
      public int x;
      public int y;
      public const int c1 = 5;
      public const int c2 = c1 + 5;

      public MyClass(int p1, int p2) 
      {
         x = p1; 
         y = p2;
      }
   }

   public static void Main() 
   {
      MyClass mC = new MyClass(11, 22);   
      Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y);
      Console.WriteLine("c1 = {0}, c2 = {1}", MyClass.c1, MyClass.c2 );
   }
}

输出

x = 11, y = 22
c1 = 5, c2 = 10

示例

该示例说明如何将常数用作局部变量。

// const_keyword2.cs
using System;
public class TestClass 
{
   public static void Main() 
   {
      const int c = 707;
      Console.WriteLine("My local constant = {0}", c);
   }
}