Monotouch/C# version of "stringWithContentsOfUrl"
Posted
by Pselus
on Stack Overflow
See other posts from Stack Overflow
or by Pselus
Published on 2010-03-22T14:29:57Z
Indexed on
2010/03/22
14:31 UTC
Read the original article
Hit count: 288
I'm trying to convert a piece of Objective-C code into C# for use with Monotouch and I have no idea what to use to replace stringWithContentsOfUrl
Should I use something like:
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.helephant.com");
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK &&
response.ContentLength > 0){
TextReader reader = new StreamReader(response.GetResponseStream());
string text = reader.ReadToEnd();
Console.Write(text);
}
Is that even safe to use in MonoTouch? Will it work for the iPhone?
© Stack Overflow or respective owner