﻿ 用ASP.NET實現一個簡單的計算器(適合入門者)_電腦知識網

# 用ASP.NET實現一個簡單的計算器(適合入門者)

2022-06-13   來源: .NET編程

文件:
Calculateaspx
bin/Calculatecs
bin/Calculatebat

步驟:
Calculatecs

namespace Calculate
{
using System;
public class math
{
public String _color;
{
return a+b;
}
public int Sub(int aint b)
{
return ab;
}
public int Mul(int aint b)
{
return a*b;
}
public String Color
{
get
{
return _color;
}
set
{
_color=value;
}
}
}
}

Calculatebat

csc /t:library /out:Calculatedll Calculatecs

執行Calculatebat

Calculateaspx

<%@Import NameSpace=Calculate%>

<script language=c# runat=server>
public String color;
{
math math=new math();
mathColor=CValue;
color=mathColor;
}
void DoSub(Object Src EventArgs E)
{
math math=new math();
MessageText=mathSub(ConvertToInt(AValue)ConvertToInt(BValue))ToString();
mathColor=CValue;
color=mathColor;
}
void DoMul(Object Src EventArgs E)
{
math math=new math();
MessageText=mathMul(ConvertToInt(AValue)ConvertToInt(BValue))ToString();
mathColor=CValue;
color=mathColor;
}

</script>
<font id=Cau color=<%ResponseWrite(color);%>>用ASP+寫得簡易計算器</font>
<form runat=server>
<input id=A runat=server/>
<input id=B runat=server/>
<input id=C runat=server/>