Determining casting of an object?

You can do this: if (this.ParentToolPane. SelectedWebPart is RssFeedReader) //... To check if it is of a certain type. Alternatively, you can use 'as' to use it as a type, and it will be null if it was not of that type.

RssFeedReader reader = this.ParentToolPane. SelectedWebPart as RssFeedReader; if (reader! = null) { //... }.

You could say RssFeedReader rss; rss = this.ParentToolPane. SelectedWebPart as RssFeedReader; if(rss! = null) { // an RssFeedReader } RssCountry rc; rc = this.ParentToolPane.

SelectedWebPart as RssCountry; if(rc! = null) { // an RssCountry } or if(this.ParentToolPane. SelectedWebPart is RssFeedReader) { // an RssFeedReader RssFeedReader rss = (RssFeedReader)this.ParentToolPane.

SelectedWebPart; } if(this.ParentToolPane. SelectedWebPart is RssCountry) { // an RssCountry RssCountry rc = (RssCountry)this.ParentToolPane. SelectedWebPart; } But, be warned.

Almost any time that you are basing your logic on the type is a bad design smell!

Thanks I decided to create a seperate class - as it smelt bad – nav Jan 20 '10 at 15:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions