Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linq Func Action
//Title of this code //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) { //Your code goes here IEnumerable<string> cities = new string[]{"Atlanta", "Warsaw", "Gliwice", "Atmonia"}; var query = cities.Filter(s => s.StartsWith("At")); var q1 = cities.Where(c => c.StartsWith("Atl")); var q2 = cities.Or foreach (var c in q1) { Console.WriteLine(c); } DateTime date = new DateTime(2015, 1, 1); int days = date.DaysToEndOfMonth(); Console.WriteLine(days); //funkcja która zwraca string i przyjmuje jeden parametr int Func<int, string> add = (x) => (x+1).ToString(); //gdy nie ma zwracanej warości to zamiast func stosujemy Action<T>, T - input parameter Action<int> write = x => Console.WriteLine(x); write(4); Console.WriteLine(add(5)); } static bool StrA(string input) { return input.StartsWith("At"); } } //Extention method to datetime, musi być w static class public static class DateUtilities { public static int DaysToEndOfMonth(this DateTime date) { return DateTime.DaysInMonth(date.Year, date.Month) - date.Day; } } public static class FilterExtention { //Extention methor for IEnumerable<string> public static IEnumerable<string> StringsThatStartWith(this IEnumerable<string> input, string start) { foreach(var s in input) { if (s.StartsWith(start)) { yield return s; } } } public static IEnumerable<T> Filter<T>(this IEnumerable<T> input, Func<T, bool> predicate) { foreach(var item in input) { if (predicate(item)) { yield return item; } } } public delegate bool FilterDelegate<T> (T item); } }
run
|
edit
|
history
|
help
0
ADSA - Tuto 1 - Exo4 - b - Proposition d'algo en O(n)
IEquatable_Object compare
Bubble sort
array integration
1 through 1000
train555555
aaaaa
Valida Fechas futuras
Problem: fb_series
C# .ToInt() Extension Method Example