简体   繁体   English

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

[英]ASP.NET C# Returning Unknown Integers for Unknown Reason

WebMethod: 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: 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 发行img http://www.taaraf.com/issue.png

Id is passed from JavaScript code as 338 correctly. Id从JavaScript代码正确传递为338。 Why does it show as 152? 为什么显示为152? This isn't allowing me to get the proper data. 这不允许我获取正确的数据。 Ideas? 有想法吗?

The number is displayed as hexadecimal, you can see this by the 0x.... . 数字显示为十六进制,您可以通过0x....看到它。 Hex 152 is Dec 338. 十六进制152是338年12月。

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

This is hexadecimal. 这是十六进制的。 It's the same number 一样的号码

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

Computers LOVE binary. 计算机喜欢二进制文件。 So representing numbers in bases that of the form 2^n is awesome for working with computers ;) 因此,以2 ^ n的形式表示数字对于使用计算机非常有用;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM