Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad code example, please improve #185

Open
waynebaby opened this issue Jan 1, 2024 · 0 comments
Open

Bad code example, please improve #185

waynebaby opened this issue Jan 1, 2024 · 0 comments

Comments

@waynebaby
Copy link

In the document:

        // Create a query
        ...
        var queryString = HttpUtility.ParseQueryString(string.Empty);
        queryString["q"] = userQuery;
        var query = "https://api.bing.microsoft.com/v7.0/search?" + queryString;
        ...

the code is depending on an implementation of ToString() in a private class HttpQSCollection, which is never descripted in any documents. NameValueCollection was never guaranteed returning a query string liked string.
By the context, the code can be easily replaced by

var query =$"https://api.bing.microsoft.com/v7.0/search?q={userQuery}";

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant