I have converted 4,000 lines of code from VB.net to c#… I am totally tripped up on this one problem. This keeps giving me the error that “Only assignment, call increment, decrement, await, and new object expressions can be used as a statement”
Any help on what the error is here? It also is throwing an error that a query body must end with a select clause or a group clause.
protected static string AssembleArgumentString(Dictionary<string, string> @params, bool urlEncode)
{
if (urlEncode) {
return string.Join("&", (from kv in @params where !string.IsNullOrEmpty(kv.Value)kv.Key + "=" + System.Web.HttpUtility.UrlEncode(kv.Value)).ToArray);
}
else {
return string.Join("&", (from kv in @params where !string.IsNullOrEmpty(kv.Value)kv.Key + "=" + kv.Value).ToArray);
}
}
You need a
selectclause in your LINQ query. For example:Also, don’t forget the
()at the end of theToArraymethod call. You actually don’t even need theToArray()becauseString.Join()can take anIEnumerableas well.