Skip to content

Commit b5ca91c

Browse files
authored
Merge pull request #41106 from Anduin2017/patch-1
Better code style.
2 parents ad23c84 + 8e50811 commit b5ca91c

File tree

1 file changed

+6
-9
lines changed
  • articles/cognitive-services/Bing-Spell-Check/quickstarts

1 file changed

+6
-9
lines changed

articles/cognitive-services/Bing-Spell-Check/quickstarts/csharp.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
7070
```csharp
7171
async static void SpellCheck()
7272
{
73-
HttpClient client = new HttpClient();
73+
var client = new HttpClient();
7474
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", key);
7575

76-
HttpResponseMessage response = new HttpResponseMessage();
76+
HttpResponseMessage response = null;
7777
// add the rest of the code snippets here (except for main())...
7878
}
7979
```
@@ -87,14 +87,11 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
8787
3. Create a list with a `KeyValuePair` object containing your text, and use it to create a `FormUrlEncodedContent` object. Set the header information, and use `PostAsync()` to send the request.
8888

8989
```csharp
90-
List<KeyValuePair<string, string>> values = new List<KeyValuePair<string, string>>();
91-
values.Add(new KeyValuePair<string, string>("text", text));
90+
var values = new Dictionary<string, string>();
91+
values.Add("text", text);
9292

93-
using (FormUrlEncodedContent content = new FormUrlEncodedContent(values))
94-
{
95-
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
96-
response = await client.PostAsync(uri, content);
97-
}
93+
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
94+
response = await client.PostAsync(uri, new FormUrlEncodedContent(values));
9895
```
9996

10097
## Get and print the API response

0 commit comments

Comments
 (0)