Statsar Statistics Library

v1.0.1 for .NET

Product Guide



More Information...

Valid XHTML


QuickStart Example (C#)

[C#]
/* COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
 * All rights reserved.
 *
 * Use of this copyright notice is precautionary only, and does not imply
 * publication or disclosure. The content of this work contains confidential
 * and proprietary information of Simplexar Software Limited. Any duplication,
 * modification, distribution, or disclosure in any form, in whole, or in part,
 * is strictly prohibited without express prior written permission.
 */

// Get namespaces.
using System;
using Simplexar.Statsar;

// Start namespace.
namespace Simplexar.Examples.Statsar
{
    /// <summary>
    /// This example loads a simple CSV file from Excel (already included as
    /// part of the distribution) and computes the average of one of the
    /// columns.
    /// </summary>
    public static class Example
    {
        /// <summary>
        /// The application entry point.
        /// </summary>
        public static void Main()
        {
            try
            {
                RunExample();
            }
            catch(Exception exception)
            {
                Console.WriteLine(exception);
            }
            Console.WriteLine("Press ENTER to terminate.");
            Console.ReadLine();
        }

        private static void RunExample()
        {
            // Create a calculator.
            StatsCalculator calculator = new StatsCalculator();
                       
            // Use the calculator to load the sheet.
            DataSheet sheet = calculator.Load(
                @"..\..\..\..\..\Data\ExamResults.csv");

            // Convert the sheet to a string for display.
            Console.WriteLine(sheet.ToString());

            // Calculate the mean of the 'EnglishResult' column.
            Console.WriteLine(calculator.Mean("EnglishResult"));
        }
    }
}