工作中经常会用到xml转class的工作,比如
<root>
<name>wang</name>
<address>toronto</address>
</root>
把它转成一个class
class root
{
public string Name { get; set;}
public string address { get; set; }
}
你当然可以手写,但是如果xml很大,会很烦人,我以前都是写一小段临时script转,最近发现vs有功能实现这一小目标
1) open visual studio
2)copy your xml string(or json string)
3) create a new class
4) click Edit-> Paste Special -> Paste XML as Classes ( or ) Paste JSON as Classes
done
shit easy..
<root>
<name>wang</name>
<address>toronto</address>
</root>
把它转成一个class
class root
{
public string Name { get; set;}
public string address { get; set; }
}
你当然可以手写,但是如果xml很大,会很烦人,我以前都是写一小段临时script转,最近发现vs有功能实现这一小目标
1) open visual studio
2)copy your xml string(or json string)
3) create a new class
4) click Edit-> Paste Special -> Paste XML as Classes ( or ) Paste JSON as Classes
done
shit easy..