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 class PersonFactory | |
{ | |
public Person GetPerson(int id) | |
{ | |
if (id > 1000) | |
{ | |
return new Employee(); | |
} | |
else | |
{ |
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
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> | |
<div ng-app=""> | |
<input type="text" ng-model="name" /> | |
<p ng-bind="name"></p> | |
</div> |
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
ObjectContext objectContext = ((IObjectContextAdapter)entities).ObjectContext; | |
Employee emp1 = new Employee() { EmployeeName = "Employee 1" }; | |
Employee emp2 = new Employee() { EmployeeName = "Employee 2" }; | |
entities.Employees.Add(emp1); | |
entities.Employees.Add(emp2); | |
entities.SaveChanges(); |
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 class Person : IComparable | |
{ | |
public string Name { get; set; } | |
public int Age { get; set; } | |
public int CompareTo(Object obj) | |
{ | |
Person otherPerson = obj as Person; | |
if (otherPerson == 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
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Person p1 = new Person() { Name = "Person 1", Age = 34 }; | |
Person p2 = new Person() { Name = "Person 2", Age = 31 }; | |
Person p3 = new Person() { Name = "Person 3", Age = 33 }; | |
Person p4 = new Person() { Name = "Person 4", Age = 26 }; | |
List<Person> people = new List<Person> { p1, p2, p3, p4 }; |
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 FactoryFunction() { | |
var obj = { | |
prop3: 3, | |
prop4: 4 | |
}; | |
return obj; | |
} | |
FactoryFunction.prototype.myMethod = function () { }; |
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 ConstructorFunction() { | |
this.prop1 = 1; | |
this.prop2 = 2; | |
} | |
ConstructorFunction.prototype.myMethod = function () { }; | |
//obj1 is assigned with prop1,2 and myMethod | |
var obj1 = new ConstructorFunction(); |
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 changeValue(val) { | |
val = val + " changed"; | |
console.log(val); //A changed | |
} | |
var val = "A"; | |
changeValue(val); | |
console.log(val); //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
public class MvcApplication : System.Web.HttpApplication | |
{ | |
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.MapRoute( | |
"Default", // Route name | |
"{controller}/{action}/{id}", // URL with parameters | |
new { controller = "Home", action = "Index", id = "" } // Parameter defaults |
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> values = new List<int>() { 1, 2, 3 }; | |
int sum = values.Sum(); //6 | |
double average = values.Average(); //2.0 |
NewerOlder