Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Learning linq 2
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Program p = new Program(); p.linq4(); } public void linq4() { int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var textNums = from n in numbers select strings[n]; Console.WriteLine("Number strings"); foreach(var s in textNums) { Console.WriteLine(s); } } public void linq3() { int [] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; var numsPlusOne= from n in numbers select n + 1; Console.WriteLine("Numbers plus 1"); foreach (var i in numsPlusOne) { Console.WriteLine(i); } } public void linq2() { String[] digits ={ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var shortDigits = digits.Where((digit, index) => digit.Length < index); var shortD = digits.Where((digit, index) => digit.Length < index); Console.WriteLine("Short digits:"); foreach (var x in shortD) { Console.WriteLine("The word {0} is shorter than its value", x); } } public void linq1() { int[] numbers = {1, 3, 4, 8, 9, 7, 4, 5, 6, 3, 2, 8, 10}; var lowNuns = from n in numbers where n < 5 select n; Console.WriteLine("Lower than 5"); foreach (var x in lowNuns) { Console.WriteLine(x); } var bigNums = from x in numbers where x >= 5 select x; Console.WriteLine("Gigger or equal than 5"); foreach(var x in bigNums) { Console.WriteLine(x); } } } }
run
|
edit
|
history
|
help
0
UrlAccess
train555555
T
Math 9.6
borrar_xml_tags_vacios
asdxcscd
Polygon Util
selam
c
Palindrome String