Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Casting errors should be caught during compiling, right?
Message
De
21/11/2004 16:25:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/11/2004 20:57:20
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Divers
Thread ID:
00963257
Message ID:
00963351
Vues:
7
>Cetin,
>
>I haven't run the code sample ... which part of it is the part that you're questioning?
>
>UPDATE: Now I *have* run the sample code. There are no errors when it's run. What problem did you have with it?
>
>~~Bonnie
>
>>Type safety and casting as I thought are closely coupled and if a type can't be casted to another type it should be caught during compilation. Or to put it another way could a method return some other type than what it's instructed to do?
>>To reproduce what I mean try MSDN code sample under:
>>System.Windows.Forms\Binding class
>>Cetin

Bonnie,
Wrong sample. Search using "datetimepicker datagrid". It'd be listed 2nd with a datetipicker control in datagrid sample. Run it and soon you'd get:
System.InvalidCastException: Specified cast is not valid.
   at DataGridTimePickerColumn.Edit(CurrencyManager source, Int32 rowNum, Rectangle bounds, Boolean readOnly, String instantText, Boolean cellIsVisible)
   at System.Windows.Forms.DataGrid.Edit(String instantText)
   at System.Windows.Forms.DataGrid.Edit()
   at System.Windows.Forms.DataGrid.set_CurrentCell(DataGridCell value)
   at System.Windows.Forms.DataGrid.set_CurrentRow(Int32 value)
   at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke)
   at System.Windows.Forms.DataGrid.ProcessKeyPreview(Message& m)
   at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
   at System.Windows.Forms.Control.WmKeyChar(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
PS: Casting to object is special case and not the thing here. It doesn't occur if you use only mouse.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform