C# Convert.ChangeType()

Convert.ChangeType() 将未知类型转换为已知类型spa

long content = 123;
object result = Convert.ChangeType(content, typeof(int));

其余经常使用的转换方法举例:code

一、Convert.ToInt32(content)blog

二、int i=Int32.Parse(content)it

三、int i=0;nt.TryParse(content,out i)class

四、int i=(Int32)contentobject

五、int? i=content as Int32 (content 必须为可为空数值)方法

相关文章
相关标签/搜索