Is Url Safe Char - CSharp System

CSharp examples for System:Char

Description

Is Url Safe Char

Demo Code

//     Copyright (c) Microsoft Corporation.  All rights reserved.
using System.Text;
using System;//from  www  .ja v a2 s  .  c  o m

public class Main{
        // Set of safe chars, from RFC 1738.4 minus '+' 
		public static bool IsUrlSafeChar( char ch ) {
			if( ( ch >= 'a' && ch <= 'z' ) || ( ch >= 'A' && ch <= 'Z' ) || ( ch >= '0' && ch <= '9' ) )
				return true;

			switch( ch ) {
				case '-':
				case '_':
				case '.':
				case '!':
				case '*':
				case '(':
				case ')':
					return true;
			}

			return false;
		}
}

Related Tutorials