2 Replies - 4469 Views - Last Post: 27 October 2010 - 09:05 PM

#1 oo123oo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 29-September 10

C++/CLR Windows Form App

Posted 27 October 2010 - 08:23 PM

I'm trying to create a very simple Windows Form Application in VS2008. I have a form named Form1 with only a button and a textbox. It's quite simple but I keep receiving an error msg saying "error C2451: conditional expression of type 'overloaded-function' is illegal
Context does not allow for disambiguation of overloaded function". Could anyone please explain to me what's wrong with my code?

Thanks!

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 String^ name = gcnew String(textBox1->Text);

				 if (name->IsNullOrEmpty)
				 {
					 MessageBox::Show("Error");
						
				 }
				 else;
			 }



Is This A Good Question/Topic? 0
  • +

Replies To: C++/CLR Windows Form App

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: C++/CLR Windows Form App

Posted 27 October 2010 - 08:53 PM

It's a static function. See here

// This example demonstrates the String.IsNullOrEmpty() method
using namespace System;
String^ Test( String^ s )
{
   if ( String::IsNullOrEmpty( s ) == true )
      return "is null or empty";
   else
      return String::Format( "(\"{0}\") is not null or empty", s );
}

int main()
{
   String^ s1 = "abcd";
   String^ s2 = "";
   String^ s3 = nullptr;
   Console::WriteLine( "String s1 {0}.", Test( s1 ) );
   Console::WriteLine( "String s2 {0}.", Test( s2 ) );
   Console::WriteLine( "String s3 {0}.", Test( s3 ) );
}

/*
This example produces the following results:

String s1 ("abcd") is not null or empty.
String s2 is null or empty.
String s3 is null or empty.

*/


Was This Post Helpful? 1
  • +
  • -

#3 oo123oo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 29-September 10

Re: C++/CLR Windows Form App

Posted 27 October 2010 - 09:05 PM

oh wow! I didn't notice isNullOrEmpty is static! I thought the error had sth to do with the message box!
thanks a lot! :rockon:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1