• 大小: 45KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-19
  • 语言: C#
  • 标签: C#  计算器  Windows  

资源简介

采用vs2010 C# 做的计算器(仿 Windows 自带的计算器 加减乘除运算)。 使用2008或05的可以新建08或05工程,将核心代码拷贝过去使用。 或者下载一个转换版本的软件将10的转换成所需版本。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator
{
    enum Op
    {
        Nothing = 5
        Add = 10
        Sub = 20
        Multi = 100
        Div = 10000
        Equal=100000
    };


    class Computer
    {
        private Op op;
        private double result;

        public Computer()
        {
            op = Op.Nothing;
            result = 0;
        }

        public void ClearResult()
        {
            op = Op.Nothing;
            result = 0;
        }

        public double GetResult()
        {
            return result;
        }



        public void Operation(string StrOp double value) 
        {
            if (op == Op.Nothing)
            {
                result = value;
            }
            else
            {
                Equal(value);
            }
            switch (StrOp)
            {
                case “+“:
                    op = Op.Add;
                    break;
                case “-“:
                    op = Op.Sub;
                    break;
                case “*“:
                    op = Op.Multi;
                    break;
                case “/“:
                    op = Op.Div;
                    break;
                case “=“:
                    op = Op.Equal;
                    break;
            
            }      
        }

        public double Equal(double value)
        {
            switch (op)
            {
                case Op.Nothing:
                    break;
                case Op.Add:
                    result += value;
                    break;
                case Op.Sub:
                    result -= value;
                    break;
                case Op.Multi:
                    result *= value;
                    break;
                case Op.Div:
                    result /= value;
                    break;
                default:
                    return result;
            }
            return result;
        }


    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      13824  2011-04-06 17:38  Calculator\bin\Debug\Calculator.exe

     文件      36352  2011-04-06 17:38  Calculator\bin\Debug\Calculator.pdb

     文件      11608  2011-06-14 21:44  Calculator\bin\Debug\Calculator.vshost.exe

     文件        490  2010-03-17 22:39  Calculator\bin\Debug\Calculator.vshost.exe.manifest

     文件       4010  2011-04-06 16:38  Calculator\Calculator.csproj

     文件       2134  2011-04-02 15:19  Calculator\Class1.cs

     文件       3457  2011-04-06 17:38  Calculator\Form1.cs

     文件      12601  2011-04-06 17:38  Calculator\Form1.Designer.cs

     文件       5814  2011-04-06 17:36  Calculator\Form1.resx

     文件       2247  2011-06-14 21:44  Calculator\obj\Debug\Calculator.csproj.FileListAbsolute.txt

     文件        847  2011-04-02 15:47  Calculator\obj\Debug\Calculator.csproj.GenerateResource.Cache

     文件      13824  2011-04-06 17:38  Calculator\obj\Debug\Calculator.exe

     文件        180  2011-04-06 17:36  Calculator\obj\Debug\Calculator.Form1.resources

     文件      36352  2011-04-06 17:38  Calculator\obj\Debug\Calculator.pdb

     文件        180  2011-04-06 16:44  Calculator\obj\Debug\Calculator.Properties.Resources.resources

     文件       4516  2011-04-06 17:38  Calculator\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6016  2011-04-06 17:38  Calculator\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        374  2011-04-06 17:36  Calculator\obj\Debug\GenerateResource-ResGen.read.1.tlog

     文件        526  2011-04-06 17:36  Calculator\obj\Debug\GenerateResource-ResGen.write.1.tlog

     文件        491  2011-03-28 15:36  Calculator\Program.cs

     文件       1376  2011-03-28 15:36  Calculator\Properties\AssemblyInfo.cs

     文件       2870  2011-03-28 15:36  Calculator\Properties\Resources.Designer.cs

     文件       5612  2011-03-28 15:36  Calculator\Properties\Resources.resx

     文件       1095  2011-03-28 15:36  Calculator\Properties\Settings.Designer.cs

     文件        249  2011-03-28 15:36  Calculator\Properties\Settings.settings

     文件        599  2011-04-06 17:36  Calculator\ShowControl.cs

     文件       1042  2011-04-02 15:57  Calculator\ShowControl.Designer.cs

     文件        920  2011-04-06 16:38  Calculator.sln

     目录          0  2011-03-28 15:54  Calculator\obj\Debug\Refactor

     目录          0  2011-03-28 15:36  Calculator\obj\Debug\TempPE

............此处省略9个文件信息

评论

共有 条评论