返回顶部

收藏

C# 中声明常量的方法

更多
class ConstantDeclarations
{
   public static void Main()
   {
   // Type          Identifier Initializer
      const bool    aBool      = true;
      const byte    aByte      = 255;
      const decimal aDecimal   = 0.99m;
      const double  aDouble    = 1.7 * 10308;
      const char    aChar      = '\uFFFF';
      const float   aFloat     = 3.4f * 1038f;
      const int     aInt       = 2147483647;
      const long    aLong      = 9223372036854775807;
      const object  aObject    = null;
      const sbyte   aSbyte     = 127;
      const uint    aUint      = 4294967295;
      const short   aShort     = 32767;
      const string  aString    = "Sample";
      const ushort  aUshort    = 65535;
      const ulong   aUlong     = 18446744073709551615;
   }
}

标签:常量,const,常量声明

收藏

0人收藏

支持

0

反对

0

发表评论