简体   繁体   中英

How to create an extension method on a class in C#?

I'd like to write an extension method for string, which appears as a static method on System.String - I've not managed to get that done.

Is that possible? If so how? Thanks!

It's not possible. Extension methods let you add what look like instance methods, and not static methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM