How to use the geoprocessor using ArcObjects

public IGeoProcessorResult ExecuteGeoProcessor(bool addOutputsToMap, string extent, IRaster snapRaster,
    string gpToolName, params object[] args)
    IGeoProcessor gp;
    IVariantArray gpParams;
    IGeoProcessorResult gpResult;
    string warningMessages;
    string errorMessages;
    // create a new geoprocessor instance
    gp = new GeoProcessorClass();
    // don't add outputs to TOC
    gp.AddOutputsToMap = addOutputsToMap;
    // set the extent
    gp.SetEnvironmentValue("extent", extent);
    // set the snap raster
    gp.SetEnvironmentValue("snapRaster", ((IRaster2)snapRaster).RasterDataset.CompleteName);
    // create a parameter array
    gpParams = new VarArrayClass();
    for (int i = 0; i < args.Length; ++i)
    // run the geoprocessing tool
    gpResult = gp.Execute(gpToolName, gpParams, null);
    warningMessages = gpResult.GetMessages(1);
    errorMessages = gpResult.GetMessages(2);
    if (errorMessages != "")
        throw new Exception(errorMessages);

    return gpResult;

ExecuteGeoProcessor(true, "MAXOF", snapRaster,
    "Watershed", fdrLayer.Name, outletFCPath, watershedRasterPath, "OutletOID");