开发者

C# - Get XElement.Value in a custom datetime format

开发者 https://www.devze.com 2023-04-01 01:11 出处:网络
Here is my problem: I have a XElement storing a DateTime, and I want to get the Value property returning the DateTime in a custom format.

Here is my problem:

I have a XElement storing a DateTime, and I want to get the Value property returning the DateTime in a custom format.

I was wondering if there is a way to include a IFormatProvider 开发者_开发知识库in the XElement.


I think you are mixing things here. The XElement always stores its value as a string. To get a custom date format, you need to convert this string into a DateTime object first and then call ToString with the format you want to have.

0

精彩评论

暂无评论...
验证码 换一张
取 消