[Mono-bugs] [Bug 25075] New - Error with Convert.ChangeType() using TypeCode

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
21 May 2002 19:25:09 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ds99krha@thn.htu.se.

http://bugzilla.ximian.com/show_bug.cgi?id=25075

--- shadow/25075	Tue May 21 15:25:09 2002
+++ shadow/25075.tmp.28916	Tue May 21 15:25:09 2002
@@ -0,0 +1,59 @@
+Bug#: 25075
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: win2k/cygwin
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ds99krha@thn.htu.se               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: Error with Convert.ChangeType() using TypeCode
+
+Description of Problem:
+Convert.ChangeType converts to the wrong type when using TypeCode.
+
+Steps to reproduce the problem:
+1. Run the code
+short tryInt16 = 1234;
+object obj;
+		
+obj = Convert.ChangeType(tryInt16, TypeCode.UInt16);
+Console.WriteLine("obj.GetType(): {0}, but should have been: 
+System.UInt16", obj.GetType());
+			
+obj = Convert.ChangeType(tryInt16, TypeCode.UInt32);
+Console.WriteLine("obj.GetType(): {0}, but should have been: 
+System.UInt32", obj.GetType());
+
+obj = Convert.ChangeType(tryInt16, TypeCode.Int64);
+Console.WriteLine("obj.GetType(): {0}, but should have been: 
+System.Int32", obj.GetType());
+
+obj = Convert.ChangeType(tryInt16, TypeCode.Char);
+Console.WriteLine("obj.GetType(): {0}, but should have been: 
+System.Char", obj.GetType());
+
+
+Actual Results:
+obj.GetType(): System.Int64, but should have been: System.UInt16
+obj.GetType(): System.Single, but should have been: System.UInt32
+obj.GetType(): System.String, but should have been: System.Int32
+obj.GetType(): System.Decimal, but should have been: System.Char
+obj.GetType(): System.Int32, but should have been: System.Int32
+
+Expected Results:
+obj.GetType(): System.UInt16, but should have been: System.UInt16
+obj.GetType(): System.UInt32, but should have been: System.UInt32
+obj.GetType(): System.Int64, but should have been: System.Int32
+obj.GetType(): System.Char, but should have been: System.Char
+
+How often does this happen? 
+All the time
+
+Additional Information: