Skip to main content

This

Il est possible de étendre une classe Normale ou static avec une méthode static.

Exemple:

public class Test
{
private string hello;

public string maMethode(string arg){
return arg;
}
// on l'extent dans n'importe que autre class avec
public static int MyStaticMethode(this Test test, string maStr)
{
if(test.maMethode(maStr)== "test")
{
return 0;
}
return 1;
}


// et on l'utilise
new Test().MyStaticMethode("test");