c# - How should I call an overloaded extension method? -


assuming have extension method:

public static string tojson(this object value, jsonserializersettings settings) {     return jsonconvert.serializeobject(value, settings); } 

and overload:

private static readonly jsonserializersettings settings = getthesettingssomeway(); public static string tojson(this object value) {     return tojson(value, settings); // (1) static call     return value.tojson(settings); // (2) using extension on "this" } 

should call overload static call or extension?

it doesn't matter. same. same method called, , il same, since extension methods are code feature, result in compiled code same.

the major problem have encountered using extension methods dynamic keyword: doesn't resolve extension methods. case should use static method. since don't here, doesn't matter.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -