用于从数据库读取数据的C#代码 [英] C# code for read data from database
问题描述
我正在使用以下代码,但它不支持c#
int n = Convert.ToInt32(Interaction.InputBox(输入sno:,搜索,20,100,100) );
我应该在Convert.ToInt32(Interaction.InputBox)的地方使用什么
实际上这段代码是直观的基本的,我想转换成c#
我尝试过:
int n = Convert.ToInt32(Interaction.InputBox(输入sno:,搜索,20,100,100));
i am using following code but it not support c#
int n = Convert.ToInt32(Interaction.InputBox("Enter sno:", "Search", "20", 100, 100));
What should I use at the place of "Convert.ToInt32(Interaction.InputBox)"
Actually this code is of visual basic and I want to convert into c#
What I have tried:
int n = Convert.ToInt32(Interaction.InputBox("Enter sno:", "Search", "20", 100, 100));
推荐答案
您可以使用VB输入框,通过指定全名:
You can use the VB input box, by specifying the full name:
string input = Microsoft.VisualBasic.Interaction.InputBox("Enter sno:", "Search", "20", 100, 100);
但是对于正确的C#解决方案,您应该创建一个表单并使用ShowDialog来显示它。
请求,不要使用Convert.ToAnything - 改为使用int.TryParse,并向用户报告问题,而不是让他们输入错误的字符时全部崩溃!
But for a "proper" C# solution you should create a form and use ShowDialog to display it.
And please, don't use Convert.ToAnything - use int.TryParse instead, and report a problem to the user instead of letting your all crash if he enters a wrong character!
这篇关于用于从数据库读取数据的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!