C#--百宝囊

目录

1.通用

1.1.转小写 大写 ----string.ToLower()、 string.ToUpper()

2.一般处理程序
2.1基础框架
3.aspx.cs

4.webapi

1.通用

1.1.转小写 大写 ----string.ToLower()、 string.ToUpper()

    //转小写
    string strLow = "hello MAN";
    strLow = strLow.ToLower();
    //结果: strLow="hello man"

    //转小写
    string strUpper = "hello WOMAN";
    strUpper = strUpper.ToUpper();
    //结果: strLow="HELLO WOMAN"

2.一般处理程序

2.1基础框架

using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DEMO.Web.modules.other
{
    /// <summary>
    /// Other 的摘要说明
    /// </summary>
    public class Other : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string strContent = "";    //要调用的方法名称
            
            //获取前台传参,将参数名全部转小写
            string HandleType = context.Request["HandlerType"].ToLower();    
            switch (HandleType)
            {
                case"loaddata":  //
                    strContent = fLoadData(context);
                    break;
            }
            context.Response.Write(strContent);
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        #region 加载内容-信息总览
        private string fLoadData(HttpContext context)
        {
            Hashtable ht = new Hashtable();  //返回内容
            ht.Add("name", "张三");
            return JsonConvert.SerializeObject(ht);    //将返回结果 转为json,序列化
        }
        #endregion


    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章