سلام بر برنامه نویسان عزیز ایران زمین 😉 در این مطلب کد Xml Serialization برای مقدار DateTime در سی شارپ #C را آماده کردم. انشاالله که این کد سی شارپ براتون مفید باشد.
کد Xml Serialization برای مقدار DateTime در سی شارپ #C :
using System;
using System.Xml.Serialization;
using System.IO;
public class MyValue1
{
[XmlText(typeof(string))]
[XmlElement(typeof(int))]
[XmlElement(typeof(double))]
public object[] All = new object[] { 321, "One", 2, 3.0, "Two" };
}
public class MyValue2
{
[XmlText(Type = typeof(MyValueType))]
public MyValueType Type;
}
public enum MyValueType
{
Small,
Medium,
Large
}
public class MyValue3
{
[XmlText(Type = typeof(DateTime))]
public DateTime CreationTime = DateTime.Now;
}
public class Test
{
static void Main()
{
Test t = new Test();
using System.Xml.Serialization;
using System.IO;
public class MyValue1
{
[XmlText(typeof(string))]
[XmlElement(typeof(int))]
[XmlElement(typeof(double))]
public object[] All = new object[] { 321, "One", 2, 3.0, "Two" };
}
public class MyValue2
{
[XmlText(Type = typeof(MyValueType))]
public MyValueType Type;
}
public enum MyValueType
{
Small,
Medium,
Large
}
public class MyValue3
{
[XmlText(Type = typeof(DateTime))]
public DateTime CreationTime = DateTime.Now;
}
public class Test
{
static void Main()
{
Test t = new Test();