sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

c#中定义常量
https://blog.csdn.net/qq_41617901/article/details/90513938

  1. static class Constants
  2. {
  3. public const double Pi = 3.14159;
  4. public const int SpeedOfLight = 300000; // km per sec.
  5. }
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. double radius = 5.3;
  11. double area = Constants.Pi * (radius * radius);
  12. int secsFromSun = 149476000 / Constants.SpeedOfLight; // in km
  13. }
  14. }

 

posted on 2022-03-22 21:48  sunny123456  阅读(253)  评论(0编辑  收藏  举报