我使用的是Visual Studio 2010和.net Framework版本4,我知道之前曾有人问过这个问题,解决方案是更改.net framewwork,我安装了.net4.7,但visual studio只接受.net4。 / p>
$this->db->query("SELECT GROUP_CONCAT( DISTINCT CONCAT(\"'\", REPLACE(user_id,
\",\", \"','\") , \"'\")) as listed_id FROM user_data");
在我的代码中,我遇到了 public void callback(IAsyncResult ar)
{
try
{
sck.EndReceive(ar);
byte[] buf = new byte[8192];
int rec = sck.Receive(buf, buf.Length, 0);
if (rec < buf.Length)
{
Array.Resize<byte>(ref buf, rec);
}
Received?.Invoke(this, buf);//ERROR HERE
sck.BeginReceive(new byte[] { 0 }, 0, 0, 0, callback, null);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
close();
Disconnected?.Invoke(this);//ERROR HERE
}
}
// recieved and disconnected
public delegate void ClientReceivedHandler(Client_Connexion sender, byte[] data);
public delegate void ClientDisconnectedHandler(Client_Connexion sender);
public event ClientReceivedHandler Received;
public event ClientDisconnectedHandler Disconnected;
的错误
无效的表达式术语“。”
仅赋值,调用,递增,递减和新对象表达式可以用作语句
是否有建议将Received?.Invoke
更改为其他格式?
我尝试了Received?.Invoke
,但问题仍未解决。
答案 0 :(得分:1)
C#6中引入了空条件运算符(?.
)。Visual Studio 2010仅支持C#4。您将需要Visual Studio 2015或更高版本:您受Visual Studio版本的限制,而不是.NET版本。
您必须使用旧模式引发事件:
var handler = Received; // The temporary copy is very important to avoid race conditions
if (handler != null)
{
handler(this, buf);
}