获取真实IP:
    }
获取代理IP:
c#方法    public static string GetViaIP()
    }

http://www.cnblogs.com/jianphu/archive/2007/05/22/756041.html

取字符串的实用方法(超过一定长度自动换行)

1        }

多个域下共享Cookie的实现

必须设置同一个域

写Cookie的代码

 1c#方法HttpCookie userEmailCookie = new HttpCookie("GCEmail");
 2c#方法        userEmailCookie.Value = email.ToString();
 3c#方法        //userEmailCookie.Expires = DateTime.Now.AddYears(1); //浏览器关闭,cookie自动过期
 4c#方法        userEmailCookie.Domain = domain;
 5c#方法        HttpContext.Current.Response.Cookies.Add(userEmailCookie);
 6c#方法
 7c#方法        HttpCookie userIdCookie = new HttpCookie("GCUserID");
 8c#方法        userIdCookie.Value = userId.ToString();
 9c#方法        userIdCookie.Expires = DateTime.Now.AddYears(1);
10c#方法        userIdCookie.Domain = domain;
11c#方法        HttpContext.Current.Response.Cookies.Add(userIdCookie);                
12c#方法        
13c#方法        HttpCookie lastLoginTime = new HttpCookie("LastLoginTime");
14c#方法        lastLoginTime.Value = DateTime.Now.ToString();
15c#方法        //lastLoginTime.Expires = DateTime.Now.AddYears(1);
16c#方法        lastLoginTime.Domain = domain;
17c#方法        HttpContext.Current.Response.Cookies.Add(lastLoginTime);
18c#方法        
19c#方法        HttpCookie userRemark = new HttpCookie("GCRemark");
20c#方法        userRemark.Value = userRemarkInfo;
21c#方法        //userRemark.Expires = DateTime.Now.AddYears(1);
22c#方法        userRemark.Domain = domain;
23c#方法        HttpContext.Current.Response.Cookies.Add(userRemark);        


这里设置的域是有意义的,比如 你的域名为www.111.com
你的asp程序和asp.net程序都放在上面
那么,你那个设置域的地方都写 www.111.com 即可

2进制、8进制、10进制、16进制...各种进制间的轻松转换(c#)

.net Framework中,System.Convert类中提供了较为全面的各种类型、数值之间的转换功能。其中的两个方法可以轻松的实现各种进制的数值间的转换:

Convert.ToInt32(string value, int fromBase):

可以把不同进制数值的字符串转换为数字,其中fromBase参数为进制的格式,只能是2、8、10及16:

如Convert.ToInt32(”0010”,2)执行的结果为2;

Convert.ToString(int value, int toBase):

可以把一个数字转换为不同进制数值的字符串格式,其中toBase参数为进制的格式,只能是2、8、10及16:

如Convert.ToString(2,2)执行的结果为”0010”

现在我们做一个方法实现各种进制间的字符串自由转换:选把它转成数值型,然后再转成相应的进制的字符串:

public string ConvertString(string value, int fromBase, int toBase)

{

  int intValue = Convert.ToInt32(value, fromBase);

  return Convert.ToString(intValue, toBase);
}

其中fromBase为原来的格式

toBase为将要转换成的格式

相关文章:

  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-13
  • 2022-01-22
  • 2022-12-23
相关资源
相似解决方案