bonjour j'ai définis une classe YearMonth
Je voudrais overrider l'operateur ++

mais je ne parviens pas a trouver la syntaxe correcte
Et je ne trouve pas d'exemple
Pour exemple voici ma dernière tentative (mais j'ai déja essayé plein de truc)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    public class C_YearMonth
    {
      public int Year {get;set;}
      public int Month {get;set;}
      public C_YearMonth(int _year,int _month)
      {
        this.Year = _year;
        this.Month = _month;
      }
 
      public override operator ++
      {
        this.Month++;
        if (this.Month > 12)
        {
           this.Year++;
           this.Month=1;
        }
      }
   }