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

本文关键字:未知 返回 整数 NET 于未知 ASP | 更新日期: 2023-09-27 18:14:23

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
            });
        });

发行imghttp://www.taaraf.com/issue.png

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

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

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

数字显示为十六进制,您可以通过0x....看到这一点。十六进制152是十进制338。

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

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形式的基数表示数字对于计算机来说是非常棒的;(