使用ip地址组件C# [英] using ip address component C#

查看:164
本文介绍了使用ip地址组件C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用名为A C#IP地址控件的组件,但我认为它有问题。因为当我增加它的值1时,它给了我一些错误的结果。例如

I am trying to use a component which named as A C# IP Address Control but it has a problem I think. because when I increase its value 1, it gives me some wrong result. forexample

ipAddressControl3.Text = "192.168.1.25";
IPAddress ipAddress1 = new IPAddress(ipAddressControl3.GetAddressBytes());
ipAddress1.Address++;
MessageBox.Show(ipAddress1.ToString());

返回:193.168.1.25!但我希望192.168.1.26

returns : "193.168.1.25" ! but I expect "192.168.1.26"

有什么问题?

这里是组件链接:< a href =http://www.codeproject.com/KB/miscctrl/IpAddrCtrlLib.aspx =nofollow noreferrer> AC#IP地址控制

编辑:也许解决方案如这个但我无法实现它..

edit : Maybe solution like this but I couldnt implemented it..

推荐答案

我将我的ip big endian转换为这样的小:

I convert my ip big endian to little like this :

int ipaddress= IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse(ipAddressControl3.Text).GetAddressBytes(), 0));

并且有效。

这篇关于使用ip地址组件C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆