Thank you Nathan, But extending the types and implementing an interface over them is more appealing than switching on type (anyone remember this in OOP history books?). But when the types are not mine then switching like the stack over flow article is way better than "if else if" approach.
Kind Regards Arjang On 27 October 2010 14:33, Nathan Stayte <[email protected]> wrote: > Stackoverflow has an example of how to do what you want > http://stackoverflow.com/questions/298976/c-is-there-a-better-alternative-than-this-to-switch-on-type > > Nathan. > > > > > I need to do something similar to do this : > > if (e.Value is Book) > { > e.Value = (e.Value as X).Title; > > } > else if (e.Value is Customer) > { > e.Value = (e.Value as Customer).FullName; > } > else > { > e.Value = "Unknown"; > } > etc. > > in DataGridView_CellFormatting even, but it just looks plain ugly. is > there way to do this in a more structured manner? > > Regards > > Arjang > >
