locked
Using C# RRS feed

  • Question

  • User686683308 posted

    Hello Everyone ! How can i validate Mac address in c# ?

    Tuesday, November 6, 2018 2:23 AM

Answers

All replies

  • User409696431 posted

    Can you elaborate?  The questions that come to my mind are:  Is this an asp.net question?  Validate whose / what MAC addresses?  And what do you mean validate - compared to what?

    Tuesday, November 6, 2018 2:43 AM
  • User686683308 posted

    I want to make sure that mac address is valid Ex: 12-21-223-1 it is invalid Mac address, so have any expression to validate mac address in c# ?

    Tuesday, November 6, 2018 4:42 AM
  • User409696431 posted

    Use Regex.  https://docs.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.match?view=netframework-4.7.2 

    A Regex pattern to match valid MAC addresses:

    ^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 6, 2018 6:46 AM
  • User-821857111 posted

    How can i validate Mac address in c# ?
    Why do you want to do this? You can't get the user's MAC address in ASP.NET.

    Tuesday, November 6, 2018 7:12 AM
  • User686683308 posted

    Thank you your resource every useful for my development 

    Tuesday, November 6, 2018 8:01 AM
  • User686683308 posted

    Thank for your suggestion, but i have to explain you. i have store user mac address in my database when user they call my wcf service to use they have input valid mac address and after mac address is valid i will check it again with my database that store mac address. Thank you ! 

    Tuesday, November 6, 2018 8:06 AM
  • User475983607 posted

    Thank for your suggestion, but i have to explain you. i have store user mac address in my database when user they call my wcf service to use they have input valid mac address and after mac address is valid i will check it again with my database that store mac address. Thank you ! 

    The MAC address identifies systems on a network and not available outside the network or in a WCF request.  

    https://en.wikipedia.org/wiki/MAC_address

    Tuesday, November 6, 2018 12:23 PM