Here is a example that showcases different files for creating objective function and constraint classes as well as the setup required for a Genetic Algorithm. There are many GA’s on the web, but this is my own – specifically created for use in OOOT.
Read why I decided to write another one.
The following code (with verbose commenting) is found in the Source Code under:

Examples->Example2 Genetic Algorithm->Program.cs

/* first a new optimization method in the form of a genetic algorithm is created.
*/

var
optMethod = newGeneticAlgorithm();

/* then an objective function and constraints are added. Since these inherit
from