当前位置:编程学习 > C#/ASP.NET >>

C#学习3

从键盘输入两个数,将其相加并输出


[csharp]
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text 
namespace abc 

    class Program 
    { 
        static void Main(string[] args) 
        { 
            (new Program()).run(); 
        } 
        public void run() 
        { 
            double left=readdouble("输入左操作数: "); 
            double right=readdouble("输入右操作数: "); 
            writefree(solve(left,right)); 
        } 
        private void writefree(double p) 
        { 
            Console.WriteLine("结果是:{0}", p); 
        } 
        private double solve(double left, double right) 
        { 
            return left * right; 
        } 
        private double readdouble(string p) 
        { 
            Console.Write(p); 
            string Line = Console.ReadLine(); 
            return double.Parse(Line); 
        } 
    } 

附个截图

 

 


补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,