using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var numbers = textBox1.Text.Split(' ');
var min = numbers.Min();
var max = numbers.Max();
textBox2.Text = string.Format("min: {0} max: {1}", min, max);
{
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
当用户键入(1 2 3 4 5 6 7 8 9 10)时,无法显示正确的最大值我对编程并不陌生,我对将max {0}更改为十来显示什么感到有些困惑。 10个而不是9个。我想知道是否有人可以提供帮助
var numbers = textBox1.Text.Split(' ')
.Select(int.Parse).ToArray();
var min = numbers.Min();
var max = numbers.Max();
在表单中添加第二个文本框,并将此行添加到所有内容下方。
textbox2.Text = string.Format("min: {0} max: {1}", min, max);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句