Click here to Skip to main content
15,907,001 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help with reading XML [modified] Pin
velkropie10-Jul-07 9:43
velkropie10-Jul-07 9:43 
QuestionExample DataGridView like Outlook... Pin
jsosa99-Jul-07 5:33
jsosa99-Jul-07 5:33 
AnswerRe: Example DataGridView like Outlook... Pin
velkropie11-Jul-07 11:40
velkropie11-Jul-07 11:40 
GeneralRe: Example DataGridView like Outlook... Pin
jsosa911-Jul-07 12:24
jsosa911-Jul-07 12:24 
GeneralRe: Example DataGridView like Outlook... Pin
velkropie13-Jul-07 10:53
velkropie13-Jul-07 10:53 
Questionunable to cast object of type 'X' to type 'X' Pin
joelbasson9-Jul-07 5:22
joelbasson9-Jul-07 5:22 
AnswerRe: unable to cast object of type 'X' to type 'X' Pin
Colin Angus Mackay9-Jul-07 5:47
Colin Angus Mackay9-Jul-07 5:47 
AnswerRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 6:02
Martin#9-Jul-07 6:02 
Hello,

joelbasson wrote:
"Unable to cast object of type 'ResponseProcessingCSP' to 'ResponseProcessingCSP'

Doesn't it say "Unable to cast object of type 'IResponseProcessingCSP' to 'ResponseProcessingCSP'"?

joelbasson wrote:
ResponseProcessingCSP inherits from type IResponseProcessingCSP

But it was instanciated as IResponseProcessingCSP, and you can not Up'cast' it , I think!

Maybe this two examples help you:
1) Your problem (You cannot make a button out of a control)
Control _control = new Control();
Button _button = _control as Button;
if(_button!=null)
{
}
else
{
	//this part of the code is executed, cause _button = null;
}

2)But you can make a Button, hold it as Control and when you need it cast it back to Button
Button _button = new Button();
Control _control = _button;
Button _newbutton = _control as Button;
if(_newbutton!=null)
{
	//this part of the code is executed, cause _newbutton != null;
}
else
{
}


Hope it helps!

P.S.: You should use the 'as' operator, which will not throw an exception, if the casting is not possible!

All the best,

Martin

GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Colin Angus Mackay9-Jul-07 7:16
Colin Angus Mackay9-Jul-07 7:16 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
PIEBALDconsult9-Jul-07 8:25
mvePIEBALDconsult9-Jul-07 8:25 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Luc Pattyn9-Jul-07 8:35
sitebuilderLuc Pattyn9-Jul-07 8:35 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 8:41
Martin#9-Jul-07 8:41 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
PIEBALDconsult9-Jul-07 13:48
mvePIEBALDconsult9-Jul-07 13:48 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Luc Pattyn9-Jul-07 14:18
sitebuilderLuc Pattyn9-Jul-07 14:18 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 8:51
Martin#9-Jul-07 8:51 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Colin Angus Mackay9-Jul-07 11:19
Colin Angus Mackay9-Jul-07 11:19 
GeneralRe: unable to cast object of type 'X' to type 'X' [modified] Pin
Martin#9-Jul-07 19:21
Martin#9-Jul-07 19:21 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 19:54
Martin#9-Jul-07 19:54 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Vikram A Punathambekar9-Jul-07 17:50
Vikram A Punathambekar9-Jul-07 17:50 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 19:35
Martin#9-Jul-07 19:35 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 19:52
Martin#9-Jul-07 19:52 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Vikram A Punathambekar9-Jul-07 20:16
Vikram A Punathambekar9-Jul-07 20:16 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Martin#9-Jul-07 20:25
Martin#9-Jul-07 20:25 
GeneralRe: unable to cast object of type 'X' to type 'X' Pin
Vikram A Punathambekar9-Jul-07 22:08
Vikram A Punathambekar9-Jul-07 22:08 
GeneralRe: unable to cast object of type 'X' to type 'X' [modified] Pin
Martin#9-Jul-07 22:49
Martin#9-Jul-07 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.