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 class C | |
| { | |
| static object M0<T>(IEnumerable<T> source) { | |
| // linq с новой строки | |
| var e1 = | |
| from item in source | |
| select item.ToString(); | |
| return e1; | |
| } |
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
| using System.Collections.Generic; | |
| using System.Collections.ObjectModel; | |
| internal static class Program | |
| { | |
| private static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key) { return default(TValue); } | |
| private static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> source, TKey key) { return default(TValue); } | |
| private static void Main() { | |
| var dictionary = new Dictionary<int, int>(); |
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
| using System; | |
| using System.ComponentModel; | |
| using System.Diagnostics; | |
| using System.Globalization; | |
| namespace Xxx.ComponentModel | |
| { | |
| public abstract class CustomPropertyDescriptor : PropertyDescriptor | |
| { | |
| protected CustomPropertyDescriptor(MemberDescriptor descr) : base(descr) { } |
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
| void M<T>(ICollection<T> source) { | |
| var a = source.Any(); // OK, statically known, that source is ICollection<T> and call is optimized | |
| var b = source.Count(); // Warning, source.Count is better | |
| } | |
| bool M1<T>(IEnumerable<T> source) { | |
| return source.Any(); // OK - one iteration in a worst case | |
| } | |
| int M1<T>(IEnumerable<T> source) { |
NewerOlder