Question:You are writing an application that uses SOAP to exchange data with other applications. You use a Department class that inherits from ArrayList to send objects to another application. The Department object is named dept. You need to ensure that the application serializes the Department object for transport by using SOAP. Which code should you use?
A SoapFormatter formatter = new SoapFormatter();
byte[] buffer = new byte[dept.Capacity];
MemoryStream stream = new MemoryStream(buffer);
foreach (object o in dept) {
formatter.Serialize(stream, o); }
B SoapFormatter formatter = new SoapFormatter();
MemoryStream stream = new MemoryStream();
foreach (object o in dept) {
formatter.Serialize(stream, o); }
C SoapFormatter formatter = new SoapFormatter();
byte[] buffer = new byte[dept.Capacity];
MemoryStream stream = new MemoryStream(buffer);
formatter.Serialize(stream, dept);
D SoapFormatter formatter = new SoapFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, dept);