类型名称 'DaysInMonth' 不存在于类型 'DateTime' [Assembly-CSharp] 中

The type name 'DaysInMonth' does not exist in the type 'DateTime' [Assembly-CSharp]

我正在使用 Unity 并想找到一个月中的几天,但我的可视化代码显示没有 DateTime.DaysInMonth()

的方法
The type name 'DaysInMonth' does not exist in the type 'DateTime' [Assembly-CSharp]

有人知道为什么吗???

DaysInMonth 方法有两个参数(月份和年份)。看看 MSDN

所以你必须像 DateTime.DaysInMonth(04, 2022) 这样调用方法。