Wednesday, July 11, 2007

Cannot implicitly convert type 'string' to 'method group'

I run into this now and again in C#: Cannot implicitly convert type 'string' to 'method group'

This usually means that you have not included the parenthesis at the end of a method call. For example, ToString(). Many times I will do:

if (str == var.ToString)

or

str = var.ToString;

It throws the about error because I needed to do:
if (str == var.ToString())

or

str = var.ToString();