日期:2014-05-18  浏览次数:20697 次

请教类型转换问题
如有一个string类型的数据,要根据用户的输入字符串来生成不同的类型,如果用户输入“int”,就把string转换成 int类型...,怎么实现呢?不用case,if之类的

------解决方案--------------------
Convert.ChangeType(object,Type.GetType("typestring"))
如:
Convert.ChangeType(object,Type.GetType("System.Int"))

System.Int为用户输入的类型,int