gpt4 book ai didi

c# - 在 C# 中的 MessageBox 中显示当前日期时间

转载 作者:行者123 更新时间:2023-11-30 13:20:19 26 4
gpt4 key购买 nike

我知道这很微不足道,但我似乎找不到答案,因为我从未用过 C#。在 Google 上搜索但没有结果。

我试图在 C# 中的 MessageBox 中显示当前日期时间,但出现以下错误

无法将日期时间转换为字符串

代码如下:

DateTime current = DateTime.Now;
MessageBox.Show(current.ToString);

最佳答案

ToString 是一种方法。你需要这样做:

MessageBox.Show(current.ToString());

关于c# - 在 C# 中的 MessageBox 中显示当前日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8847516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com