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
using System.Text.RegularExpressions; | |
public string removeHTML(string input) | |
{ | |
string pattern = @"<(.|\n)*?>"; | |
Regex regex = new Regex(pattern, RegexOptions.Singleline); | |
string output = regex.Replace(input, string.Empty); | |
return output; |
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
public static class EncryptConnection | |
{ | |
public static void EncryptConnectionString(bool encrypt) | |
{ | |
Configuration configFile = null; | |
try | |
{ | |
// Open the configuration file and retrieve the connectionStrings section. | |
configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); | |
ConnectionStringsSection configSection = configFile.GetSection("connectionStrings") as ConnectionStringsSection; |
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
public static IDictionary<string, object> ToDictionary(this object data) | |
{ | |
BindingFlags publicAttributes = BindingFlags.Public | BindingFlags.Instance; | |
Dictionary<string, object> dictionary = new Dictionary<string, object>(); | |
foreach (PropertyInfo property in data.GetType().GetProperties(publicAttributes)) | |
{ | |
if (property.CanRead) | |
dictionary.Add(property.Name, property.GetValue(data, null)); | |
} |
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
Regex.Replace("ThisIsMyCapsDelimitedString", "(\\B[A-Z])", " $1") |
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
public static class StringExtensions | |
{ | |
public static bool IsNumeric(this String str) | |
{ | |
double temp; | |
return double.TryParse(str, out temp); | |
} | |
} |
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
delegate string DelegateTest(string str); | |
DelegateTest delTest = new DelegateTest(Class1.Hello); | |
Console.WriteLine(delTest("LOL")); | |
class Class1{ | |
... | |
public static string Hello(string msg) { | |
return "Hello " + msg; | |
} |
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
public string ConvertStringToHex(string asciiString) | |
{ | |
string hex = ""; | |
foreach (char c in asciiString) | |
{ | |
int tmp = c; | |
hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString())); | |
} | |
return hex; | |
} |
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
namespace Sandbox | |
{ | |
public class Country | |
{ | |
public string Name { get; set; } | |
public string ThreeLetterAbbr { get; set; } | |
public string TwoLetterAbbr { get; set; } | |
} | |
class Program |
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
Dictionary<String, String> stateabbrs = new Dictionary<string,string>(); | |
stateabbrs.Add("Alabama","AL"); | |
stateabbrs.Add("Alaska","AK"); | |
stateabbrs.Add("Arizona","AZ"); | |
stateabbrs.Add("Arkansas","AR"); | |
stateabbrs.Add("California","CA"); | |
stateabbrs.Add("Colorado","CO"); | |
stateabbrs.Add("Connecticut","CT"); | |
stateabbrs.Add("Delaware","DE"); | |
stateabbrs.Add("Florida","FL"); |
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
public static bool IsDate(this string sdate) | |
{ | |
DateTime dt; | |
bool isDate = true; | |
try { | |
dt = DateTime.Parse(sdate); | |
} | |
catch { | |
isDate = false; |