I'm trying to replace this for-each
loop with Linq
query. This loop is killing the performance. str
contains list<string>
. I have to read one by one each string from str
and encode it then I need to publish it to the server using AMQ
.
foreach (var item in str)
{
byte[] bytes = Encoding.UTF8.GetBytes(item);
publisher.SendMessage(bytes);
}