Ask coding questions

← Back to all posts
Method group + field
Bunnytoes

When I try it to replace Style with style, it throws an error saying error CS0118: `MainClass.style' is a `field' but a `method group' was expected please help

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Bunnytoes
Comments
hotnewtop
Coder100

uh it works for me? confirm it actually saved

Bunnytoes

@Coder100 it works because I didn't replace the Style with style in lines 11-21 I'll show you

Coder100

@Bunnytoes well, as you may know, style is a class (method group), and not a function.

Bunnytoes

@Coder100 it says it was expecting a method group main.cs(11,5): error CS0118: `MainClass.style' is a `field' but a `method group' was expected

Coder100

yeah that's literally a class??? @Bunnytoes

Bunnytoes

@Coder100 yes look at style.cs

Coder100

exactly and you can't call a class did you mean styles.Style? @Bunnytoes

Bunnytoes

@Coder100 I fixed it, thanks

Coder100