简体   繁体   中英

How to split two values in one textBox

How to split the values in one textBox using / as a separator?

Value format: 192.168.0.0/24

Two textBoxes are currently used, and this is not convenient:

在此处输入图片说明

Simply use Split method:

string str = "192.168.0.0/24";
var result = str.Split('/');
Console.WriteLine(result[0]); // ip
Console.WriteLine(result[1]); // mask

Demo

Another possible way is :

       string value = "192.168.0.0/24";
        Console.WriteLine(value.Split('/').First()); 
        Console.WriteLine(value.Split('/').Last());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM