How to check internet connection using c#

There are many ways you can check in your c# application that internet on the machine is working or not. Sometimes you have such operations in your application which need an internet connection. So this post might be useful for you if you want to check before such operation if user has internet connection or not.

Simply use the following code and that’s it 🙂

add this namespace first in your form or class where you need this function.

then place the following code in your class.

That’s it now simply you can use this function where ever you need it like: (note i declare it as static, its up to you how you need it.)

Your feedback and comments are always welcome. If you have some other method for same purpose please share it as well.





Sumbal Gee Junior Programmer Asked on February 28, 2013 in General Question.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.