.NET WebClient: Where is DownloadString?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 01:57:23

问题


I'm probably missing something here, but when I use WebClient and look for the DownloadString method (as found in a book example), I only see DownloadStringAsync.

What Import am I missing?


回答1:


Are you using Silverlight? Only the Async version is available in Silverlight. Otherwise, the .NET 4 Framework and below (except 1.x) have the DownloadString() method.

http://msdn.microsoft.com/en-us/library/ms144200.aspx




回答2:


as indicated here, it looks like the DownloadString method is part of System.Net.




回答3:


Well, I think you're creating a Silverlight application. In that case it is a normal thing: you will find usually only asynchronous methods in Silverlight applications; this makes your UI more responsive because operations will be executed in another thread without blocking it.

Try to create a desktop application (Console Application, WPF, etc.) and you will find the method you're looking for.



来源:https://stackoverflow.com/questions/4247724/net-webclient-where-is-downloadstring

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!