我有一个 IP 地址,我想将最后一块作为整数抓取。所以从"192.168.1.150"
我得到150
.
这是我编写的代码(我使用的是 C++/CLI),但不知何故感觉相当笨拙:
String^ ipString = "192.168.1.150";
int lastDot = ipString->LastIndexOf('.');
int lastSection = int::Parse(ipString->Substring(lastDot, ipString->Length-lastDot));
有没有更简单的方法来做到这一点?