【发布时间】:2021-02-13 00:53:14
【问题描述】:
我正在尝试制作一个 iOS 应用程序来计算二次方程。我对所有这些 UIKit 的东西都很陌生,所以经过很长时间试图弄清楚如何解决这个问题,我仍然没有答案,因此我为什么要问这个问题。我正在尝试让一个按钮在 2 个框中显示 2 个不同的答案,就像您在二次方程中所做的那样。我不知道我可能做错了什么,我不知道这是否是这段代码之外的东西。提前致谢。
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);
}
}
}
}
【问题讨论】:
-
这是什么编程语言?
-
这个语言是c#。
标签: c# ios xcode visual-studio mobile-development