예제 #1
0
        /// <summary>
        ///   Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// 
        /// <param name="format">The format.</param>
        /// <param name="formatProvider">The format provider.</param>
        /// 
        /// <returns>
        ///   A <see cref="System.String"/> that represents this instance.
        /// </returns>
        /// 
        public string ToString(string format, IFormatProvider formatProvider)
        {
            formatter f = new formatter();
            f.format = format;
            f.provider = formatProvider;

            return String.Format("{0}x {1}y {2}z {3} = 0",
                f.s(A), f.s(B), f.s(C), f.s(Offset));
        }
예제 #2
0
        /// <summary>
        ///   Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// 
        /// <param name="variable">The variable to put on the left hand side. Can
        ///   be either 'x', 'y' or 'z'.</param>
        /// <param name="formatProvider">The format provider.</param>
        /// 
        /// <returns>
        ///   A <see cref="System.String"/> that represents this instance.
        /// </returns>
        /// 
        public string ToString(char variable, IFormatProvider formatProvider)
        {
            formatter f = new formatter();
            f.provider = formatProvider;

            switch (variable)
            {
                case 'x': return String.Format("x = {0}y {1}z {2}",
                        f.s(-B / A), f.s(-C / A), f.s(-Offset / A));

                case 'y': return String.Format("y = {0}x {1}z {2}",
                        f.s(-A / B), f.s(-C / B), f.s(-Offset / B));

                case 'z': return String.Format("z = {0}x {1}y {2}",
                        f.s(-A / C), f.s(-B / C), f.s(-Offset / C));

                default:
                    throw new FormatException();
            }
        }