Reputation: 37500
Why does this work:
using namespace System;
using namespace System::Windows::Forms;
...
if( MessageBox::Show("Really do it?", "Are you sure?", System::Windows::Forms::MessageBoxButtons::YesNo) == System::Windows::Forms::DialogResult::Yes )
{
Console::WriteLine("Do it!");
}
..when this fails:
using namespace System;
using namespace System::Windows::Forms;
...
if( MessageBox::Show("Really do it?", "Are you sure?", System::Windows::Forms::MessageBoxButtons::YesNo) == DialogResult::Yes )
{
Console::WriteLine("Do it!");
}
...with the following error:
error C2039: 'Yes' : is not a member of 'System::Windows::Forms::Form::DialogResult'
I'm assuming Visual Studio is picking up DialogResult but I can't see where it's finding it?
Upvotes: 3
Views: 3077
Reputation: 26730
System::Windows::Forms::Form
has a property also called DialogResult (being of type System::Windows::Forms::DialogResult
), hence the error.
http://msdn.microsoft.com/library/system.windows.forms.form.dialogresult.aspx
http://msdn.microsoft.com/library/system.windows.forms.dialogresult.aspx
Upvotes: 3
Reputation: 6359
It's a naming collision, Form.DialogResult is a property of Form. See here. I assume your code is part of a Form and thus that takes precedence.
Upvotes: 3