Free cookie consent management tool by TermsFeed Policy Generator
wiki:Documentation/DevelopmentCenter/DeveloperGuidelinesSourceExample

Version 1 (modified by swagner, 16 years ago) (diff)

created separate wiki page for source code example of CodingConventions

Source Code Example

/* A multiline comment
 * describing something ...
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace HeuristicLab.Core {
  public class Sheep : Mammal, IAnimal {
    private double myWeight;
    public double Weight {  // a comment
      get { return myWeight; }
      set {
        if (value > 0)
          myWeight = value;
      }
    }


    public Sheep() {
      myWeight = 666;
    }
    public Sheep(double weight) {
      myWeight = weight;
    }


    // a comment describing a method
    public string LookABitSilly() {
      return "Oo";
    }

    public override string ToString() {
      return "Sheep (" + Weight.ToString() + " tons)";
    }

    public event EventHandler Baa;
    protected virtual void OnBaa() {
      if (Baa != null)
        Baa(this, new EventArgs());
    }
  }
}