I have a computer on the local network, behind a NAT router. I have some 192.168.0.x addresses, but I really want to know my public IP address, not something mentioned in
How to get the IP address of the server on which my C# application is running on?
or
How to get the IP address of a machine in C#
I need C# code.
Is it possible? If so, how?
Below code will help you to take public IP address
Depending on the router you use, chances are pretty good that you could get it directly from the router. Most of them have a web interface, so it would be a matter of navigating to the correct web page (e.g., "192.168.0.1/whatever") and "scraping" the external IP address from that page. The problem with this is, of course, that it's pretty fragile -- if you change (or even re-configure) your router, chances are pretty good that it'll break.
you may be able to use uPNP and fall-back to whatsmyip.com if that fails.