2025年春江苏开放大学.NET架构与项目开发实训第二次作业答案
一、单选题
1、当json字符串调用
voidclient_DownloadStringcompleted(object
sender,DownloadStringCompletedEventArgse)
{
weatherClasswdeserialize(e.Result)
showMsg(e.Result);
}
结果是什么?
A、json对象
B、json字符串
C、以上答案都不对
D、xml字符串
正确答案:B
2、Stringserialize(Tobj)
{
_____
MemoryStreammsnewMemoryStream();
json.WriteObject(ms,obj)
StringsEncoding.UTF8.GetString(ms.ToArray());
returns;
}
序列化函数serialize缺少的语句是:
A、以上说法都不对
B、DataContractSerializerjsonnewDataContractSeria
DataContractSerializerlizer(typeof(WeatherClass));
C、XmlSerializerxmlnewXmlSerializer(typeof(WeatherClass));
D、DataContractSerializerjsonDataContractSerializer(typeof(WeatherClass));
正确答案:B
3、当json字符串调用
voidclient_DownloadStringcompleted(object
sender,DownloadStringCompletedEventArgse)
{
weatherClasswdeserialize(e.Result);
showMsg(w.Tostring());
}
结果是什么?
A、以上都不对
B、json反序列化结果
C、json字符串
D、xml字符串
正确答案:B
4、下面程序下载的字符串:
try
{
WebClientclientnewWebClient();
client.EncodingEncoding.UTF8;
client.DownloadStringCompleted+client_DownloadStringCompleted;
UriurinewUri(“”,UriKind.Absolute);
client.DownloadStringAsync(uri);
msg.Text”OK”;
}
catch(Exceptionexp){msg.Textexp.Message;}
在执行client.DownloadStringAsync(uri)后
A、程序等待服务器响应,然后显示msg.Text”OK”;
B、程序不等待服务器响应,就显示msg.Text”OK”;
C、程序client.DownloadStringCompleted+client_DownloadStringCompleted有错
误
D、以上说法都不对
正确答案:B
5、Stringserialize(WeatherClassw)
{
_____
MemoryStreammsnewMemoryStream();
xml.Serialize(ms,w);
StringsEncoding.UTF8.GetString(ms.ToArray());
returns;
}
序列化函数serialize缺少的语句是:
A、XmlSerializerxmlXmlSerializer(typeof(WeatherClass));
B、以上说法都不对
C、XmlSerializerxmlnewXmlSerializer(typeof(WeatherClass));
D、XmlSerializerxmlXmlSerializer(WeatherClass);
正确答案:C
6、Tdeserialize(Strings)
{
XmlSerializerxmlnewXmlSerializer(typeof(T));
byte[]bufEncoding.UTF8.GetBytes(s);
MemoryStreammsnewMemoryStream(buf);
Tobj(T)xml.Deserialize(ms);
returnobj;