ASP.NET C#因未知原因返回未知整数

时间:2011-11-12 02:00:06

标签: c# jquery asp.net sql ajax

的WebMethod:

[WebMethod]
public static string[] GetLikes(int Id)
{
    List<Like> Likes = Like.GetById(Id, false);
    string[] Senders = new string[Likes.Count];
    for (int i = 0; i < Likes.Count; i++)
    {
        Senders[i] = Likes[i].Sender;            
    }
    return Senders;
}

jQuery的:

        $(".StreamLike").live("mouseover", function () {

            var Id = $(this).parent().parent().find(".StreamIndex").html();
            alert(Id);
            $.ajax({
                type: 'POST',
                url: 'Default.aspx/GetLikes',
                data: JSON.stringify({ "Id": Id }),
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: LikesSuccess,
                error: LikesError
            });
        });

issue img http://www.taaraf.com/issue.png

ID正确地从JavaScript代码传递到338。为什么它显示为152?这不允许我获得正确的数据。 想法?

3 个答案:

答案 0 :(得分:1)

数字显示为十六进制,您可以通过0x....查看。 Hex 152是Dec 338。

答案 1 :(得分:1)

Id以十六进制表示法显示(以0x开头),0x152等于338。

答案 2 :(得分:1)

这是十六进制的。这是相同的数字

0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

计算机爱二进制。因此,在2 ^ n形式的基础中表示数字对于使用计算机来说非常棒;)