This file contains hidden or 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> | |
| <body> | |
| <table> | |
| <% | |
| set conn=Server.CreateObject("ADODB.Connection") | |
| conn.Provider="Microsoft SQL Server" | |
| conn.Open "Server=SQLPROD;Database=HR;UserID=SuperDuperAdmin;Password=ABC123!!!" | |
| set rs=Server.CreateObject("ADODB.recordset") | |
| sql="SELECT ID, Name, FavoriteColor " & | |
| "FROM Employees " & |
This file contains hidden or 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
| internal IEnumerable<Employee> GetEmployees1(string lastName) { | |
| var query = | |
| from emp in context.Employee | |
| where emp.LastName.StartsWith(lastName) | |
| orderby emp.LastName, emp.FirstName | |
| select new Employee { | |
| Id = emp.Id, | |
| Name = emp.FirstName + ' ' + emp.LastName, | |
| FavoriteColor = emp.FavoriteColor ?? "Green" | |
| }; |
This file contains hidden or 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
| select Id, FirstName + ' ' + LastName as Name, coalesce(FavoriteColor, 'Green') as FavoriteColor | |
| from Employees | |
| where LastName like '[whatever you passed in]%' | |
| order by LastName, FirstName |
This file contains hidden or 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
| internal class ForLoopAdder : IIntegerAdder | |
| { | |
| public int Add(int[] values) | |
| { | |
| int sum = 0; | |
| int count = values.Length; | |
| for (int i = 0; i < count; i++) | |
| { | |
| int value = values[i]; | |
| sum += value; |
This file contains hidden or 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
| internal class GotoAdder : IIntegerAdder | |
| { | |
| public int Add(int[] values) | |
| { | |
| int sum = 0; | |
| int count = values.Length; | |
| int index = 0; | |
| BEGIN: | |
| if (index == count) goto RETURN; | |
| int value = values[index++]; |
This file contains hidden or 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
| internal unsafe class ArrayPointerAdder : IIntegerAdder | |
| { | |
| public int Add(int[] values) | |
| { | |
| int sum = 0; | |
| int count = values.Length; | |
| fixed (int *p = values) | |
| { | |
| for (int i = 0; i < count; i++) | |
| { |
This file contains hidden or 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
| internal class ForEachLoopAdder : IIntegerAdder | |
| { | |
| public int Add(int[] values) | |
| { | |
| int sum = 0; | |
| foreach (var value in values) | |
| { | |
| sum += value; | |
| } | |
| return sum; |
This file contains hidden or 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
| internal class EnumeratorAdder : IIntegerAdder | |
| { | |
| public int Add(int[] values) | |
| { | |
| IEnumerator<int> enumerator = values.AsEnumerable().GetEnumerator(); | |
| int sum = 0; | |
| while (enumerator.MoveNext()) | |
| { | |
| sum += enumerator.Current; | |
| } |
This file contains hidden or 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
| static void Main() { | |
| foreach (var line in TellJokeAboutMice()) | |
| { | |
| Console.WriteLine(line); | |
| } | |
| } | |
| private static IEnumerable<string> TellJokeAboutMice() | |
| { | |
| yield return "MR MICE."; |
This file contains hidden or 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 Add(values) { | |
| let sum = 0 | |
| const length = values.length | |
| for (var i = 0; i < length; i++) { | |
| sum += values[i] | |
| } | |
| return sum | |
| } |
OlderNewer