```
public class Solution {
public int[] TwoSum(int[] nums, int target) {
int[] result = new int[2];
Dictionary<int, int> tmp = new Dictionary<int, int>();
int i;
for (i = 0; i < nums.Length && !tmp.ContainsKey(target - nums[i]); i++) {
if (!tmp.ContainsKey(nums[i])) {
tmp.Add(nums[i], i);
}
}
result[0] = tmp[target - nums[i]];
result[1] = i;
return result;
}
}
```