Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 操作员'==';无法应用于类型为';字节[]和#x27;和';字符串';|编辑_C#_Arrays_String_Byte - Fatal编程技术网

C# 操作员'==';无法应用于类型为';字节[]和#x27;和';字符串';|编辑

C# 操作员'==';无法应用于类型为';字节[]和#x27;和';字符串';|编辑,c#,arrays,string,byte,C#,Arrays,String,Byte,这是我之前收到的修复此问题的代码。我不确定在我的代码中放在哪里。请帮忙 这是出现错误的部分: Encoding.ASCII.GetString(o.Username) == textBox1.Text 当您尝试编译时,会出现此错误,对吗 我认为你的问题实际上是你的查询没有引号 这: 应该是: var query = from o in test.Users where o.Username == textBox1.Text && o.Password == textBox2.t

这是我之前收到的修复此问题的代码。我不确定在我的代码中放在哪里。请帮忙

这是出现错误的部分:

Encoding.ASCII.GetString(o.Username) == textBox1.Text

当您尝试编译时,会出现此错误,对吗

我认为你的问题实际上是你的查询没有引号

这:

应该是:

var query = from o in test.Users
where o.Username == textBox1.Text && o.Password == textBox2.text
select o;

查询是一个字符串,所以需要用引号括住=右边的所有内容。这会告诉编译器它是一个字符串文字,而不是更多的代码。

不要重新发布来编辑它。只需点击帖子上的链接。应该删除此问题,并编辑另一个问题,以解决它存在的任何问题。
o.Password==textBox2.Text
->您应该对用户密码进行哈希运算,最好是使用salt。不应该简单地进行平等性检查。如果有人入侵你的数据库,他们会得到你所有的用户详细信息和明文密码。这是Linq,不是SQL查询。即使是SQL查询,它也不是有效的查询。您可以了解Linq查询语法。
var query = from o in test.Users
where o.Username == textBox1.Text && o.Password == textBox2.text
select o;
var query = "from o in test.Users" +
"where o.Username == textBox1.Text && o.Password == textBox2.text" + 
"select o";