public TemperatureData Convert(TemperatureData t)
 {
     if (t.Unit == "C")
     {
         t.Value = (t.Value * 1.8m) + 32;
         t.Unit  = "F";
     }
     else
     {
         t.Value = (t.Value - 32) / 1.8m;
         t.Unit  = "C";
     }
     return(t);
 }
        public void ProcessRequest(HttpContext context)
        {
            decimal         value = Convert.ToDecimal(context.Request["Value"]);
            string          unit  = Convert.ToString(context.Request["Unit"]);
            TemperatureData t     = new TemperatureData();

            if (unit == "C")
            {
                t.Value = (value * 1.8m) + 32;
                t.Unit  = "F";
            }
            else
            {
                t.Value = (value - 32) / 1.8m;
                t.Unit  = "C";
            }
            JavaScriptSerializer json = new JavaScriptSerializer();
            string jsonString         = json.Serialize(t);

            context.Response.ContentType = "application/json";
            context.Response.Write(jsonString);
        }