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
IEnumerable<int> example1 = Enumerable.Range(1, 10); | |
var example2 = Enumerable.Reverse(example1); | |
List<int> example3 = example1.Reverse().ToList(); |
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
String s = default(String); //null | |
int i = default(int); //0 | |
bool b = default(bool); //false | |
Program p = default(Program); //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
(function a() { | |
a(); | |
})(); |
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
//.NET 1.0 | |
ArrayList list = new ArrayList(); | |
list.Add(i); | |
int j = (int)list[0]; | |
//With Generics | |
List<int> list = new List<int>(); | |
list.Add(i); | |
int j = list[0]; |
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
class Program | |
{ | |
static void Main() | |
{ | |
GenericList<int> intList = new GenericList<int>(); | |
GenericList<string> stringList = new GenericList<string>(); | |
} | |
} |
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 MyDelegate(string val); | |
static void Main(string[] args) | |
{ | |
MyDelegate del = n => { | |
string s = n + "!!!"; | |
return s; | |
}; | |
var delValue = del("Hello"); //Hello!!! |
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
class Program | |
{ | |
delegate int Delegate1(); | |
delegate int Delegate2(int a); | |
delegate int Delegate3(int a, int b); | |
static void Main(string[] args) | |
{ | |
//No parameters | |
Delegate1 del1 = () => PrintValue(); |
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 int MultiplyDelegate(int x); | |
static void Main(string[] args) | |
{ | |
MultiplyDelegate multi = x => x * x; | |
int result = multi(4); //16 | |
} |
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 void PrintDelegate(string message); | |
PrintDelegate printer = delegate(string message) | |
{ | |
Console.WriteLine(message); | |
}; |
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
class BaseClass | |
{ | |
public virtual string Name { get; set; } | |
} | |
class DerivedClass : BaseClass | |
{ | |
public override string Name | |
{ | |
get |