有人可以帮我这个...我只是无法找到错误的位置...因为即使我输入正确的用户名和密码弹出一条消息说指定的演员无效
if (user_txt.Text != "" & pass_txt.Text != "")
{
string queryText = "SELECT Count(*) FROM stiguidancesample.users " + "WHERE username = @Username AND password = @Password";
MySqlConnection cn = new MySqlConnection(MyConnectionString);
MySqlCommand cmd = new MySqlCommand(queryText, cn);
{
cn.Open();
cmd.Parameters.AddWithValue("@Username", user_txt.Text); // cmd is SqlCommand
cmd.Parameters.AddWithValue("@Password", pass_txt.Text);
int result = (int)cmd.ExecuteScalar();
if (result > 0)
MessageBox.Show("Loggen In!");
else
MessageBox.Show("User Not Found!");
}
}
Run Code Online (Sandbox Code Playgroud) 即使我调整窗体窗口的大小,如何才能使图片框始终锁定在 winforms 应用程序的右上角?
我尝试这样做:
pictureBox1.Margin = new Padding(5,5,0,0);
Run Code Online (Sandbox Code Playgroud)
但这没有用。我希望它始终从顶部填充 5 个,从右侧填充 5 个。无论表单窗口的大小是多少。
每当我声明一个enum,它就不会编译.我的代码看起来像这样:
private enum race {HUMAN, ORC, GOBLIN, UNDEAD}
// The name of the player
string playerName;
// The Health Points of the player. Is to be modified a LOT. Keep that in mind!
int HP = 100;
// Made to test if the name chosen i the right one
bool nameIsRight = false;
cout("Hello fair traveler!\n\n");
cout("It has come to my knowledge, that you, a puny warrior, is up for the challenge, that is killing the dragon\n\n");
cout("Our …Run Code Online (Sandbox Code Playgroud) 以此为例:
#include <memory>
#include <iostream>
int add(int a, int b) {
return a+b;
}
std::unique_ptr<int> addp(int a, int b) {
std::unique_ptr<int> ip(new int(a + b));
return ip;
}
int main(int argc, char const* argv[])
{
std::cout << add(3, 5) << std::endl;
std::cout << *(addp(3, 5)) << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
功能addp是否会提高性能,或者换句话说,是否可以避免复制数据?我怀疑结果a+b是在堆栈中,然后以任何方式复制到堆中.
当我阅读 C# 中的扩展方法时,我看到了下面的代码:
public static class ExtensionMethods
{
public static string UpperCaseFirstLetter(this string value)
{
if (value.Length > 0)
{
char[] array = value.ToCharArray();
array[0] = char.ToUpper(array[0]);
return new string(array);
}
return value;
}
}
class Program : B
{
static void Main(string[] args)
{
string value = "dot net";
value = value.UpperCaseFirstLetter();
Console.WriteLine(value);
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
我评论了“返回新”礼物这一行并运行该程序。现在编译器读取代码“返回值”。如果我运行程序而不注释该行,则编译器不会读取“返回值”行。C# 中 return 和 return new 有什么区别?
我需要一个非常简单的问题的帮助.如何在不创建包装根对象的情况下将下面的json反序列化为C#bool.谢谢.
f
{"valid":false}
0
Run Code Online (Sandbox Code Playgroud) 我只想弄清楚像List这样的不可变的东西是如何工作的,以及我如何为它添加东西?
我很抱歉问这些愚蠢的问题,但是为什么我的列表在打印时总是空的?
var end = false
val list = List()
while (!end) {
val input = scala.io.StdIn.readLine("input:")
if (input == "stop" ) end = true
else input :: list
}
println(list)
}
Run Code Online (Sandbox Code Playgroud)
很抱歉给我带来不便和这个相当愚蠢的问题!
我有Label我的Form.当我调用Dispose()方法时,对象从中移除Form.但我仍然可以设置它的属性.在Dispose()为对象调用Method 之后会发生什么.我可以恢复它并再次显示它吗?
public void MyMethod()
{
label1.Dispose();
label1.Text = "Test";
//No error happens
}
Run Code Online (Sandbox Code Playgroud)
在处理之后我可以读取一些属性,如Left属性.这意味着标签仍然存在于某个地方.我怎么能完全删除它?
我的自定义按钮实际上是一个按钮,它是否违反了LSP?
class ConditionalButton : Button
{
protected override void OnClick(EventArgs e)
{
if (Condition())
base.OnClick(e);
}
private bool Condition()
{
//return true or false
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试用C#编写程序来查明数字是否为素数.我使用前两个if语句来挑出许多选项,然后我试图在最后的else语句中嵌套一个循环,它告诉我有"检测到无法访问的代码".
public static bool primeNumber ()
{
Console.Write ("Please enter a number to see if it is a prime number: ");
int num = int.Parse (Console.ReadLine ());
if (num % 2 == 0)
return false;
else if (num % 5 == 0)
return false;
else {
for (int i = 3; i < num / 2; i += 2)
{
if (num % i == 0)
return false;
else
return true;
}
}
}
Run Code Online (Sandbox Code Playgroud) c# ×8
add ×1
asp.net ×1
c++ ×1
dispose ×1
enums ×1
if-statement ×1
immutability ×1
json ×1
list ×1
oop ×1
padding ×1
picturebox ×1
scala ×1
winforms ×1