convert.toString

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

I have datetime variable:

DateTime datum;

I set it and when I try to put it into a label:

labelDate.Text =datum.ToShortDateString;

I get an error:

Error 5 Cannot convert method group 'ToShortDateString' to non-delegate type
'string'. Did you intend to invoke the method?

I don't understand why this error?

labelDate.text is type of string and also datum.ToShortDateString should
return string.

It works if I use convert.toString function, but I don't know why I should
use convert function if both sides of equation are string?

Regards,Simon
 
Hello simon,

Don't forget the () after you call the ToShortDateString() method.

-chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top