Xin chỉ giáo trong C# làm sao chuyển một String ( từ TextBox.Text ) có giá trị ví dụ như "127.0.0.1" thành một biến kiểu IPAddress để xài.
Xin chỉ giáo trong C# làm sao chuyển một String ( từ TextBox.Text ) có giá trị ví dụ như "127.0.0.1" thành một biến kiểu IPAddress để xài.
try this
System.Net.IPAddress.Parse(string IPString)
Ngoài ra, nếu string là một domain thì dùng Dns.Resolve() để DNS
Code:IPHostEntry hostInfo = Dns.Resolve(hostString); IPAddress[] address = hostInfo.AddressList; IPAddress ip = address[0];
Bookmarks