Look at this code which I surrounded by textchanged event of a text box:
string testString = comboIPAddress.Text;
string[] parts = testString.Split('.');
int? ipclass = int.Parse(parts[0]);
if (ipclass == null)
{
//do nothing
}
if (ipclass >= 1 && ipclass <= 126)
{
comboSubnet.Text = "255.0.0.0";
}
if (ipclass >= 192 && ipclass <= 223)
{
comboSubnet.Text = "255.255.255.0";
}
if (ipclass >= 128 && ipclass <= 191)
{
comboSubnet.Text = "255.255.0.0";
}
else
{
comboSubnet.Text = "";
}
While executing the exe if I delete everything from IPAddress combo box, it is giving error(Input string was not in a correct format.). I don't know the other way to compare an int to null. Please help.