1

I created a string extension method

 public static string ShortID(this string id)
 {
     return id.Substring(5);
 }

When I want to compare two strings using this extension method like this

if(Id.ShortID == IdDest.ShortID)

I have an error :

 CS0019: impossible to apply operator == to operands of type "group of methods" and "group of methods"

I don't understand why, because this extension method returns a string so logically I could compare the results as strings no ?

Vincent Ducroquet
  • 864
  • 4
  • 14
  • 24
  • 1
    If you don't use parentheses after the method name, it's just a method group name, not an actual method invocation. See duplicates. – Peter Duniho Apr 07 '21 at 22:47

1 Answers1

0

You have to add parentheses to have method calls

if(Id.ShortID() == IdDest.ShortID())
NineBerry
  • 26,306
  • 3
  • 62
  • 93