如何使用c#在asp.net中将字符串转换为bigint

如何使用c#在asp.net中将字符串转换为bigint

问题描述:

如何使用c#在asp.net中将字符串转换为bigint。



我已将Refid视为Bigint。

所以,我想要将文本框值转换为BIGINT



how to convert string to bigint in asp.net using c#.

I have taken Refid as Bigint.
So,i want to convert textbox value to BIGINT

Query = "select * from demo where Refid=" + __________(TextBox1.Text);

您的查询将在没有任何转换的情况下正常工作。只需确保在发送到查询之前验证在文本框中输入的值。
You query is going to work just fine without any conversion. Just make sure that the value entered in the textbox is validated before sending to the query.


您好,



您可以使用以下转换内容。

Hi,

You can use the following things for conversion.
textboxvaluehere.ToInt64();
Convert.ToInt64(textbox value here);

Int64.Parse(textbox value here);
Int64.TryParse(your textbox value, out parameter);





使用这些方法中的任何一种,您将得到要解析的整数。但请记住,您的文本框包含有效输入。



谢谢



Use any one of these method and you will get the integer to be parsed. But remember that your textbox contains a valid input.

Thanks


最简单的方法是使用Convert.ToInt,例如从演示中选择*,其中Refid =+ Convert.ToInt64(TextBox1.Text);



但是,如果您不确定该字符串是否为整数,则可能会出现问题。

在这种情况下,您可以考虑使用 Int64.TryParse [ ^ ]。
It is easiest to use Convert.ToInt e.g. select * from demo where Refid=" + Convert.ToInt64(TextBox1.Text); .

However, this can be a problem if you are not sure if the string is an integer.
In this case, you can consider using Int64.TryParse[^].