?? sumservice.asmx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace Example_11_17
{
/// <summary>
/// Summary description for SumService.
/// </summary>
[WebService(Name="Example_11_17:使用ASP.NET的Web服務——算術Web服務")]
public class SumService : System.Web.Services.WebService
{
public SumService()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
#region Component Designer generated code
//Required by the Web Services Designer
private IContainer components = null;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
// WEB SERVICE EXAMPLE
// The HelloWorld() example service returns the string Hello World
// To build, uncomment the following lines then save and build the project
// To test this web service, press F5
[WebMethod(Description="求和")]
public string SUMValue(string a,string b)
{
int valuea = 0;
int valueb = 0;
try
{
valuea = Int32.Parse(a);
valueb = Int32.Parse(b);
}
catch
{
return("輸入的不是整數,請重新輸入!??!");
}
return((valuea + valueb).ToString());
}
[WebMethod(Description="求差")]
public string SUBValue(string a,string b)
{
int valuea = 0;
int valueb = 0;
try
{
valuea = Int32.Parse(a);
valueb = Int32.Parse(b);
}
catch
{
return("輸入的不是整數,請重新輸入?。。?quot;);
}
return((valuea - valueb).ToString());
}
[WebMethod(Description="求積")]
public string MUTLIValue(string a,string b)
{
int valuea = 0;
int valueb = 0;
try
{
valuea = Int32.Parse(a);
valueb = Int32.Parse(b);
}
catch
{
return("輸入的不是整數,請重新輸入?。。?quot;);
}
return((valuea * valueb).ToString());
}
[WebMethod(Description="求商")]
public string DIVValue(string a,string b)
{
int valuea = 0;
int valueb = 0;
try
{
valuea = Int32.Parse(a);
valueb = Int32.Parse(b);
if(valueb == 0)
{
return("輸入錯誤,除數為0,請重新輸入?。?!");
}
}
catch
{
return("輸入的不是整數,請重新輸入?。。?quot;);
}
return((valuea / valueb).ToString());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -