开发者

Universal Parse Primitive Type on C#

I have string value and Type of some variable (For example int and "32"开发者_C百科 or bool and true). My type is primitive type. Can I parse string to my type in one line?


Yes.

Convert.ChangeType(value, type);


object res = Convert.ChangeType("123", myType);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜