Created
May 5, 2015 15:10
-
-
Save llCorvinSll/3718a6625524ca5aaa9b to your computer and use it in GitHub Desktop.
IPv6 full string from IPAddress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() { string str = "2a00:1450:4010:c04::71"; System.Net.IPAddress addr = System.Net.IPAddress.Parse(str); var bytes = addr.GetAddressBytes(); var preferredFormatString = string.Format("{0:x2}{1:x2}:{2:x2}{3:x2}:{4:x2}{5:x2}:{6:x2}{7:x2}:{8:x2}{9:x2}:{10:x2}{11:x2}:{12:x2}{13:x2}:{14:x2}{15:x2}", bytes [0], bytes [1], bytes [2], bytes [3], bytes [4], bytes [5], bytes [6], bytes [7], bytes [8], bytes [9], bytes [10], bytes [11], bytes [12], bytes [13], bytes [14], bytes [15]); Console.WriteLine (preferredFormatString); Console.Write(addr); } // Define other methods and classes here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment