Programming in C# — Question 126
You have a C# application.
The application requires 500 MB of available memory.
You need to identify whether there is enough available memory when the application starts.
Which class should you use?
Answer options
- A. OutOfmemoryException
- B. MemoryStream
- C. PerformanceCounter
- D. DiagnosticsConfigurationHandler
Correct answer: C
Explanation
The correct choice is C, PerformanceCounter, as it allows monitoring system performance, including memory usage, to ensure sufficient resources are available. The other options do not provide a way to check available memory: A is an exception for out-of-memory situations, B is for memory operations, and D pertains to handling diagnostics configuration, none of which relate to checking available memory.