Question:

You need to write a code segment that performs the following tasks:

Retrieves the name of each paused service.

Passes the name to the Add method of Collection1.

Which code segment should you use?

 

A ManagementObjectSearcher searcher =
new ManagementObjectSearcher();
searcher.Scope = new ManagementScope("Win32_Service"); foreach (ManagementObject svc in searcher.Get()) {
if ((string)svc["State"] == "Paused") {
Collection1.Add(svc["DisplayName"]);
}
} 

B ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
"Select * from Win32_Service", "State = 'Paused'");
foreach (ManagementObject svc in searcher.Get()) {
Collection1.Add(svc["DisplayName"]);
} 

C ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
"Select * from Win32_Service where State = 'Paused'"); foreach (ManagementObject svc in searcher. Get()) {
Collection1.Add(svc["DisplayName"]);
} 

D ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
"Select * from Win32_Service");
foreach (ManagementObject svc in searcher.Get()) {
if ((string) svc["State"] == "'Paused'") {
Collection1.Add(svc["DisplayName"]);
}
} 

+ Answer
+ Report
Total Preview: 968

Copyright © 2024. Powered by Intellect Software Ltd