C# 中的常量可以是什么类型?

B站影视 2025-01-27 13:14 2

摘要:public class Constants{public const int MaxAttempts = 5; // 整数常量public const double GoldenRatio = 1.618; // 浮点型常量public const stri

public class Constants{public const int MaxAttempts = 5; // 整数常量public const double GoldenRatio = 1.618; // 浮点型常量public const string CompanyName = "ABC"; // 字符串常量public const char FirstLetter = 'C'; // 字符常量public const bool IsDebugMode = false; // 布尔常量public const Days WeekendStart = Days.Friday; // 枚举常量}public enum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }

来源:面试八股文

相关推荐