Error: Extension methods must be defined in a top level static class (CS1109)

左心房为你撑大大i 提交于 2019-11-28 13:43:42

The error message says exactly what's wrong: your IntExt method isn't a top-level static class. It's a nested static class. Just pull it out of MainForm and it'll be fine.

I know this question is old, but in case anyone else runs into this problem...

Check to make sure that the keyword "this" is not in the parameter name definition (usually from copy/paste or drag)

So, replace:

public static string AddZero(this int i)

with this:

public static string AddZero(int i)

That should solve your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!