ILOG CPLEX 11.0 User's Manual > Languages and APIs > ILOG Concert Technology for .NET Users > Solve

After you have added lines to your application to build a model, you are ready for the next steps: adding lines for solving and displaying the solution.

Step 13   -  

Solve

Go to the comment Step 13 in Dietlesson.cs, and add this statement to solve the problem.

         if ( cplex.Solve() ) { 

Step 14   -  

Display the solution

Go to the comment Step 14 in Dietlesson.cs, and add the following lines to display the solution.

            System.Console.WriteLine();
            System.Console.WriteLine("Solution status = " 
                                     + cplex.GetStatus());
            System.Console.WriteLine();
            System.Console.WriteLine(" cost = " + cplex.ObjValue);
            for (int i = 0; i < nFoods; i++) {
               System.Console.WriteLine(" Buy" 
                                        + i 
                                        + " = " 
                                        + cplex.GetValue(Buy[i]));
            }
            System.Console.WriteLine();
         }

Step 15   -  

End and free license

Go to the comment Step 15 in Dietlesson.cs, and add this statement to free the license used by ILOG CPLEX.

         cplex.End();