Readline,Writeline和Convert! [英] Readline, Writeline, And Convert !

查看:146
本文介绍了Readline,Writeline和Convert!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正处于暑假,我想做一个快速的小型应用程序. wieght转换器!

我收集了最困难的信息:
1磅= 0.45359237千克.
1公斤= 2.20462262磅.

我构建了一个Windows窗体应用程序,其中包含两个文本框和一个botton.

我已经在botton内编写了一些代码来进行如下转换:

hey guys,

I''m at the summer break, and I''ve wanted to make a quick small application; the wieght converter!

I''ve gathered the hardest information which is:
1 pound = 0.45359237 kg.
1 kg = 2.20462262 pounds.

I''ve constructed a windows form application with two text boxes and one botton.

I''ve written some code inside the botton to make the conversion like below :

<pre lang="cs">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Wieght_Converter_Tool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double   a,b ;

            textBox1.Text = Console.ReadLine(); //read box1
            a = Convert.ToDouble(textBox1.Text); // assign to a


            b = a * (0.45359237);



            textBox2.Text = b.ToString();

        }
    }
}




我真的很沮丧,这个小应用程序让我头疼,而且我已经花了整整一个小时在网上搜索解决问题的方法,但是没有办法.

请帮助我,我一个人在家,根本不能问任何导师或真正的程序员.
我只能问像您这样的程序员,像蛋糕般轻巧地解决这个问题.
再次感谢您收听并尝试解决我的问题.




I''m really depressed that this tiny application has given me a headache, ans I''ve stayed a full hour searching online for a way to solve the problem, but no way, there wasn''t.

please help me, I''m alone at home, and just can''t ask any tutor or a real programmer.
I just can ask programmers like you who solve this problem like a peice of cake.
Thanks again for listening and trying to solve my problem.

推荐答案

使用System;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing;
使用System.Linq;
使用System.Text;
使用System.Windows.Forms;

命名空间Wieght_Converter_Tool
{
公共局部类Form1:Form
{
公共Form1()
{
InitializeComponent();
}

private void button1_Click(对象发送者,EventArgs e)
{
双a,b;

一个= Convert.ToDouble(textBox1.Text); //分配给


b = a *(0.45359237);



textBox2.Text = b.ToString();

}
}
}
尝试这个...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Wieght_Converter_Tool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
double a,b ;

a = Convert.ToDouble(textBox1.Text); // assign to a


b = a * (0.45359237);



textBox2.Text = b.ToString();

}
}
}
try this...


为什么要使用console.readline(),只需从键盘读取值到文本框,然后将其转换为double.do这样即可.
why you are using console.readline() ,just read the value from keyboard to textbox,then convert it into double.do like this.


这篇关于Readline,Writeline和Convert!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆