1

I'm working on a program and I need to turn a string into a array so I can turn each letter in that string to some thing else but I can't get to work it keeps giving me the following error.

Error :

"Cannot convert method group 'To Char Array' to non-delegate type 'char[]'. Did you intendto invoke the method?"

C# code :

char [] typedArray = typed.ToCharArray;
Amith
  • 6,818
  • 6
  • 34
  • 45
James
  • 45
  • 1
  • 3
  • 13

1 Answers1

5

ToCharArray is a method, not a property, so it's invocation requires parenthesis:

char[] typedArray = typed.ToCharArray();

typed.ToCharArray (without the parenthesis) is a method group, which could be converted to a delegate, but that's not what you want to do here.

Community
  • 1
  • 1
Heinzi
  • 167,459
  • 57
  • 363
  • 519