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
void Main() | |
{ | |
Console.WriteLine ("Reflection \n"); | |
//Create SampleClass objec | |
Console.WriteLine ("\n"); | |
Console.Write("1)Create SampleClass object => new SampleClass(): \n"); | |
var myObj = new SampleClass(); | |
//Get the Type information |
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
void Main() | |
{ | |
//Inspired By: http://stackoverflow.com/questions/19123506/jaro-winkler-distance-algorithm-in-c-sharp | |
//Inspired By: http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance | |
Console.Write(string.Format("distance(apple,mela): {0} \n",JaroWinklerDistance.distance("apple","apple"))); | |
Console.Write(string.Format("distance(aa,ab): {0} \n",JaroWinklerDistance.distance("aa","ab"))); | |
Console.Write(string.Format("distance(apple,aplpe): {0} \n",JaroWinklerDistance.distance("apple","aplpe"))); | |
Console.Write(string.Format("distance(apple,pear): {0} \n",JaroWinklerDistance.distance("apple","pear"))); | |
Console.Write(string.Format("distance(apple,Banana): {0} \n",JaroWinklerDistance.distance("apple","Banana"))); |
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
void Main() | |
{ | |
//for (Int32 i = 0; i < 10; i++) Console.WriteLine(i); | |
ExampleFunctiona.ForEach(Enumerable.Range(0, 10), View); | |
} | |
public void View (int i) | |
{ | |
Console.WriteLine(i); |
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
//Inspired By: http://www.dotnetperls.com/levenshtein | |
void Main() | |
{ | |
Console.Write(string.Format("distance(aunt,aunt): {0} \n",LevenshteinDistance.Compute("aunt", "ant"))); | |
Console.Write(string.Format("distance(Sam,Samantha): {0} \n",LevenshteinDistance.Compute("Sam", "Samantha"))); | |
Console.Write(string.Format("distance(flomax,volmax): {0} \n",LevenshteinDistance.Compute("flomax", "volmax"))); | |
//Out: | |
//distance(aunt,aunt): 1 | |
//distance(Sam,Samantha): 5 |
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
void Main() | |
{ | |
DbServer dbServer = DatabaseFactory.GetDb("Ms Sql Server"); | |
string dbName = dbServer.GetDbServerName(); | |
Console.WriteLine("Server Name : " + dbName); | |
dbServer = DatabaseFactory.GetDb("Oracle Database Server"); | |
dbName = dbServer.GetDbServerName(); |
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
void Main() | |
{ | |
Expression<Func<string, bool>> validationString = s => s.Length > 5; | |
Func<string, bool> validate = validationString.Compile(); | |
//Test Validate:Hello | |
var result = validate("Hello"); | |
Console.WriteLine("validate(Hello):"+result); | |
//Test Validate:Good Evening | |
result = validate("Good Evening"); | |
Console.WriteLine( "validate(Good Evening):"+result); |
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
void Main() | |
{ | |
var mySourceStringArray = new string[] { "1", "2", "3", "4"}; | |
var myDestinationStringList = new List<string>(); | |
mySourceStringArray.ForEach(myDestinationStringList.Add); | |
myDestinationStringList.ForEach(x => Debug.Write(x + " ")); | |
} | |
public static class EnumerableExtension |
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
var colors = [ "blue","blue", "red", "yellow", "green", "grey" ]; | |
$("*").find("*").each(function() { | |
$(this).css("border-color", colors[(Math.floor(Math.random() * (5 - 1 + 1)) + 1)] ).css("border-style","solid").css("border-width","medium"); | |
}); |
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
var colors = [ "blue","blue", "red", "yellow", "green", "grey" ]; | |
$("*").find("div").each(function() { | |
$(this).css("border-color", colors[(Math.floor(Math.random() * (5 - 1 + 1)) + 1)] ).css("border-style","solid").css("border-width","medium"); | |
}); |
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
//LINQPad | |
//CSharp_Pattern_Dependency_Injection_Create.cs | |
void Main() | |
{ | |
Client client = new Client(new Service()); | |
client.Start(); | |
} | |
public interface IService | |
{ |
OlderNewer