Certainly! Here's an example of a simple web API in C# that acts like a basic calculator:

csharp

using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace CalculatorAPI.Controllers
{
    public class CalculatorController : ApiController
    {
        [HttpGet]
        [Route("api/calculator/sum")]
        public IHttpActionResult Sum(int num1, int num2)
        {
            int result = num1 + num2;
            return Ok(result);
        }

        [HttpGet]
        [Route("api/calculator/subtract")]
        public IHttpActionResult Subtract(int num1, int num2)
        {
            int result = num1 - num2;
            return Ok(result);
        }

        [HttpGet]
        [Route("api/calculator/divide")]
        public IHttpActionResult Divide(int num1, int num2)
        {
            if (num2 == 0)
            {
                return BadRequest("Cannot divide by zero.");
            }

            double result = (double)num1 / num2;
            return Ok(result);
        }
    }
}

In this example, we define a CalculatorController class that derives from ApiController in the System.Web.Http namespace. The controller has three methods for performing sum, subtraction, and division operations, respectively.

Each method is decorated with the [HttpGet] attribute to indicate that they respond to HTTP GET requests. The [Route] attribute is used to specify the URL route for each operation.

To use this API, you need to create a web application and configure routing. You can use ASP.NET Web API or ASP.NET Core to create the application and set up the routing.

Remember to install the required NuGet packages (Microsoft.AspNet.WebApi for ASP.NET Web API or Microsoft.AspNetCore.Mvc for ASP.NET Core) and configure the necessary routing to make the API accessible.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence