C# 与';字符串。包含(字符串)和#x27;有一些无效的参数和参数';1';:无法从';char';至';字符串'; /5。显示收到的消息: Console.WriteLine(“[Server]接收到客户端消息”); 字符串元音=“aeiouAEIOU”; 对于(int i=0;i
无法理解为什么编译后会不断出现错误。Contains()需要一个字符串,而您给它一个字符 请尝试以下方法:C# 与';字符串。包含(字符串)和#x27;有一些无效的参数和参数';1';:无法从';char';至';字符串'; /5。显示收到的消息: Console.WriteLine(“[Server]接收到客户端消息”); 字符串元音=“aeiouAEIOU”; 对于(int i=0;i,c#,string,sockets,char,C#,String,Sockets,Char,无法理解为什么编译后会不断出现错误。Contains()需要一个字符串,而您给它一个字符 请尝试以下方法: // 5. Display the received message: Console.WriteLine("[Server] Message of client recieved"); string vowels = "aeiouAEIOU"; for (int i = 0; i < totalBytes;
// 5. Display the received message:
Console.WriteLine("[Server] Message of client recieved");
string vowels = "aeiouAEIOU";
for (int i = 0; i < totalBytes; i++)
{
aChar = Convert.ToChar(incomingDataBuffer[i]);
Console.Write(aChar);
if ("aeiouAEIOU".Contains(aChar)) vowels += aChar;
Console.Write("[Server] Vowel characters deteced: " + vowels);
}
string.Contains()需要一个字符串,您给它一个字符
请尝试以下方法:
// 5. Display the received message:
Console.WriteLine("[Server] Message of client recieved");
string vowels = "aeiouAEIOU";
for (int i = 0; i < totalBytes; i++)
{
aChar = Convert.ToChar(incomingDataBuffer[i]);
Console.Write(aChar);
if ("aeiouAEIOU".Contains(aChar)) vowels += aChar;
Console.Write("[Server] Vowel characters deteced: " + vowels);
}
您可以使用Contains方法将字符串转换为char[]。 您可以在Linq上尝试以下内容:
if ("aeiouAEUIO".Contains(aChar.ToString()))
vowels += aChar;
您可以使用Contains方法将字符串转换为char[]。 您可以在Linq上尝试以下内容:
if ("aeiouAEUIO".Contains(aChar.ToString()))
vowels += aChar;