日期:2014-05-17  浏览次数:21111 次

调用方法是否会改变原来的值

public class mypage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int UserId = 0;
        UserGroup group = null;//一个类,里面多个字段,这里就距离里面一个年龄int参数age
        doit(group ,UserId);...
        Response.Write("UserId:" + UserId +"<br>");//输出结果是0
        Response.Write("group.age:" + group.age+"<br>");//输出结果是1000
    }
    private void doit1(UserGroup group,int UserId)
    {
        UserId = 1000;
        group.age = 1000;
    }
}

为什么输出结果会这样呢,方法调用什么时候值会改变啊?

------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

另请问,一段字符在A页面
先DES加密,然后UrlEncode

传递到B页面,Request.QueryString获得参数值
先UrlDecode,然后DES解密,解密[前]是否需要先Replace(' ', '+')


DES加密完应该是二进制吧,建议使用Base64编码,再在网上传输。
Convert.ToBase64String

上次看到有人说用Base64编码,要把=Replace成%的那种,一直都没明白为什么要。
请问这个Base64可否直接传输,要不要再encode decode呢



应该是还需要urlEncode,但是发现net自己就有封装好的函数:

HttpServerUtility.UrlTokenEncode 
ncodes a byte array into its equivalent string representation using base 64 digits, which is usable for transmission on the URL.

msdn: http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urltokenencode(v=vs.100).aspx