is there a way how to convert string from textbox in this format (00:15:5D:03:8D:01) to MacAddress variable? I'm using PcapDotNet library.
C# Convert string from textbox to MacAddress
933 views Asked by Torrado36 At
2
is there a way how to convert string from textbox in this format (00:15:5D:03:8D:01) to MacAddress variable? I'm using PcapDotNet library.
You can use the string constructor:
As you can see from the code linked, it will throw an exception if you don't pass in a valid mac address. You could perform a check before you pass it in:
This ensures that all characters are :, 0-9, a-f (and A-F), and that there are 6 sections and the total length is 17. This will help you avoid getting an exception if an invalid mac is entered.