Accord.Math.Optimization.LinearConstraint.TryParse C# (CSharp) Method

TryParse() public static method

Attempts to create a LinearConstraint from a System.String representation.
public static TryParse ( string str, CultureInfo culture, IObjectiveFunction function, LinearConstraint &constraint ) : bool
str string The string containing the constraint in textual form.
culture System.Globalization.CultureInfo The culture information specifying how /// numbers written in the should /// be parsed. Default is CultureInfo.InvariantCulture.
function IObjectiveFunction The objective function to which this constraint refers to.
constraint LinearConstraint The resulting constraint, if it could be parsed.
return bool
        public static bool TryParse(string str, CultureInfo culture,
            IObjectiveFunction function, out LinearConstraint constraint)
        {
            // TODO: implement this method without the try-catch block.

            try
            {
                constraint = new LinearConstraint(function, str, culture);
            }
            catch (FormatException)
            {
                constraint = null;
                return false;
            }

            return true;
        }

Same methods

LinearConstraint::TryParse ( string str, IObjectiveFunction function, LinearConstraint &constraint ) : bool