シニア
2026年8月19日バグを見つけろ:.NET
コードは1つ。バグを見つけるか、バグがないことを示してください。
csharp
1using System.Collections.Generic;
2
3public class RequestCounter
4{
5 private readonly Dictionary<string, int> _counts = new();
6 private readonly object _lock = new();
7
8 public void Increment(string endpoint)
9 {
10 lock (_lock)
11 {
12 if (!_counts.ContainsKey(endpoint))
13 _counts[endpoint] = 0;
14 _counts[endpoint]++;
15 }
16 }
17
18 public int GetCount(string endpoint)
19 {
20 return _counts.TryGetValue(endpoint, out var count) ? count : 0;
21 }
22}問題のある行をクリックしてください。
あなたの判断
1日1回まで。回答するとすぐに正解が表示されます。
連続記録を守る
アカウントを作成すると連続記録を保存し、進捗を追跡できます。