What is the difference between a == b and a.equals(b) ?

a == b means comparision between two variables.

a.equals(b) means comparision between two objects.

...S.VinothkumaR.

What is the difference between Int.parse and Convert.ToInt32

Both the int.Parse and Convert.ToInt32 will return the same result. But the null handling only difference between them.

For example,
string str = "15";
int Val1= Convert.ToInt32(str);
int Val2= int.Parse(str);

From the above code, both Val1 and Val2 return the value as 15. Suppose the string value str has null value, Convert.ToInt32 will return zero and int.Parse will throw ArgumentNullException error.

For example,
string str=null;
int Val1= Convert.ToInt32(str);
int Val2 = int.Parse(str); //This will throw ArgumentNullException Error

That's it...

S.VinothkumaR.

Get xml from a URL

Get xml from a URL

Hi all,
Using HTTPWebRequest and Response, we can easily get the xml file. FYI, see the below code.

First of all, we need to add the following namespaces in our application.

using System.Xml;
using System.IO;
using System.Text;
using System.Net;

Just copy the following code in your button_click event (or as your wish whichever event).

string url = "your url";
Uri fileUrl = new Uri(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fileUrl);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader reader = new StreamReader(receiveStream, encode);
string strValue = reader.ReadToEnd();


Now the whole xml file in strValue variable.

...S.VinothkumaR.