如何将0x00000026之类的数字转换为38之类的数字

时间:2017-01-13 11:53:18

标签: sql-server entity-framework linq

我在SQL中有一个存储过程,当我运行这个存储过程时,我得到数字38,但当我尝试在C#中运行它时,我得到数字0x00000026

如何将其转换为“正常”数字?

存储过程:

ALTER PROCEDURE Registration 
    (@UserName nvarchar(50), 
     @Password nvarchar(9), 
     @FirstName nvarchar(50),
     @LastName nvarchar(50), 
     @EmailAddress nvarchar(50),
     @BDate date, 
     @IdentityNumber nvarchar(50), 
     @RoleID int)
AS
   IF (SELECT COUNT(1) FROM Users WHERE UserName =@UserName) = 1
   BEGIN
       RETURN -1 
   END ELSE
   BEGIN
       INSERT INTO Users(UserName, Password, FirstName, LastName, Email, IdentityNumber, BirthDate, RoleID)
       VALUES(@UserName, @Password, @FirstName, @LastName, @EmailAddress, @IdentityNumber, @BDate, @RoleID)

       RETURN  Cast(@@IDENTITY as INT)
   END

和数据访问层代码:

User test1 = DB.Users.Where(u => u.UserName == "223321").ToList();

var test2 = from users in DB.Users
            where users.UserName == "223321"
            select new
                    {
                        users.UserName,
                        users.UserID
                    };

1 个答案:

答案 0 :(得分:1)

监视窗口允许您以十六进制模式查看变量值。  这是非常简单的功能,只需右键单击Watch窗口并取消选择十六进制显示。

enter image description here

因此,单击取消选择输出的'十六进制显示选项-'38'