如何在C#中将uint转换为int?

如何在C#中将uint转换为int?
给定:

 uint n = 3;

int i = checked((int)n); //throws OverflowException if n > Int32.MaxValue
int i = unchecked((int)n); //converts the bits only 
                           //i will be negative if n > Int32.MaxValue

int i = (int)n; //same behavior as unchecked

要么

int i = Convert.ToInt32(n); //same behavior as checked

– 编辑

包括Kenan E. K.提及的信息

http://stackoverflow.com/questions/1131843/how-do-i-convert-uint-to-int-in-c

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:如何在C#中将uint转换为int?