Categories

Category Specific RSS

Is Internet Connection Available in C sharp

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.NetworkInformation;

namespace Common { public static class MailHelper {

public static bool InternetConnectionAvailable( ) { bool result = false; Ping ping = new Ping( ); PingReply reply = null; try { reply = ping.Send( “www.google.com” ); result = reply.Status == IPStatus.Success; } catch ( Exception ) […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Validate Recaptcha in C sharp

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Net; using System.IO; using System.Web.Mvc;

namespace WeBlog.Core { public static class RecaptchaUtils { public static JsonResult ValidateRecaptcha( string privateKey, string remoteip, string challenge, string response) { string postData = String.Format(“privatekey={0}&remoteip={1}&challenge={2}&response={3}”, privateKey, remoteip, challenge, response); JsonResult result = new JsonResult(); byte[] postDataBuffer = System.Text.Encoding.ASCII.GetBytes(postData);

Uri serviceUri = […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

A basic web client in C sharp

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Net;

public class MainClass { public static void Main() { System.Net.WebClient Client = new WebClient(); Stream strm = Client.OpenRead(“http://www.google.com”); StreamReader sr = new StreamReader(strm); string line; while ((line = sr.ReadLine()) != null) { Console.WriteLine(line); } strm.Close(); } }

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

find the hostname for a known IP address

find the hostname for a known IP address

find the hostname for a known IP address

using System; using System.Net; class GetAddress { public static void Main(string[] argv) { if (argv.Length != 1) { Console.WriteLine("Usage: GetAddress address"); return; } IPAddress test = IPAddress.Parse(argv[0]); IPHostEntry iphe = Dns.GetHostByAddress(test); Console.WriteLine("Information for {0}"

[…]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

degrees to radians conversion

degrees to radians conversion

degrees to radians conversion

using System;

namespace csharp { class Class1 { static void Main(string[] args) { double degrees; double radians; degrees = 50; radians = (Math.PI / 180) * degrees; Console.WriteLine(radians); } } }

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare