简体   繁体   English

为什么我不能在方法中使用我的方法?

[英]Why can't I use my methods within a method?

I am trying to make an iOS app to calculate quadratic equations.我正在尝试制作一个 iOS 应用程序来计算二次方程。 I am fairly new to all this UIKit stuff so after long days of trying to figure out how I could fix this, I still have no answer, hence why I am asking this question.我对所有这些 UIKit 的东西都很陌生,所以经过很长时间试图弄清楚如何解决这个问题,我仍然没有答案,因此我问这个问题。 I am trying to make a button display 2 different answers in 2 boxes, as you would, in a quadratic equation.我正在尝试让一个按钮在 2 个框中显示 2 个不同的答案,就像您在二次方程中所做的那样。 I do not know what I may have done wrong and I don't know if it's something external to this code.我不知道我可能做错了什么,我不知道这是否是这段代码之外的东西。 Thanks in advance.提前致谢。

using Foundation;
using System;
using UIKit;
using static System.Net.Mime.MediaTypeNames;

namespace Quadeq
{
    public partial class ViewController : UIViewController
    {
        public ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.
        }

        public static void Calculatebutton_TouchUpInside(UIButton sender)
        {
            static void idk(Answer1 hi, Textfield3 c, Textfield2 b, textfield1 a, bool pos)
            {
                string quad = Convert.ToString(quadform(a, b, c, true));
                hi.Text = quad;

            }
            static void idek(Answer2 heyy, Textfield3 c, Textfield2 b, textfield1 a, bool pos)
            {
                string quad = Convert.ToString(quadform(a, b, c, false));
                heyy.Text = quad;

            }
            idk();
            idek();
        }

        static void idk(Answer1 hi, Textfield3 c, Textfield2 b, textfield1 a, bool pos)
        {
            string quad = Convert.ToString(quadform(a, b, c, true));
            hi.Text = quad;
        }
        static void idek(Answer2 heyy, Textfield3 c, Textfield2 b, textfield1 a, bool pos)
        {
            string quad = Convert.ToString(quadform(a, b, c, false));
            heyy.Text = quad;
        }
        static int Textnumber1(UITextField t)
        {
            int num = int.Parse(t.Text);
            return num;
        }
        static double quadform(textfield1 a, Textfield2 b, Textfield3 c, bool pos)
        {
            int okay = Textnumber1(a);
            int owkie = Textnumber1(b);
            int yay = Textnumber1(c);

            var preRoot = owkie * owkie - 4 * okay * yay;
            if (preRoot < 0)
            {
                return double.NaN;
            }
            else
            {
                var sgn = pos ? 1.0 : -1.0;
                return (sgn * Math.Sqrt(preRoot) - owkie) / (2.0 * okay);
            }

        }
    }
}

It seems that you aren't passing any arguments to the methods when calling them调用它们时,您似乎没有将任何 arguments 传递给方法

idk();
idek();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM