class MyClass { public int MyProperty { get; set; } } static void Main() { // ä¾ã¨ãã¦ããããªé åããã£ãã¨ãã¾ã var mc1 = new MyClass { MyProperty = 3 }; var mc2 = new MyClass { MyProperty = 3 }; var array = new[] { mc1, mc2 }; // Distinctã¯éè¤ãåãé¤ããã§ãçµæã¨ãã¦ãããã¯ã2ã§ãã var result = array.Distinct().Count(); // åç §ã®æ¯è¼ãªã®ã§å½ç¶ã§ããã§ã¯ãMyPropertyã®å¤ã§æ¯è¼ãããã£ããï¼ // Distinctã«ã¯IEqualityComparerã¤ã³ã¹ã¿ã³ã¹ãåãä»ãããªã¼ãã¼ãã¼ããããã¾ã // ãããIEqualit
ããæ°æ¥Twitterã§è¦ã/åºããLinqãã¿ã¾ã¨ããç§ã®åºããªã観測ç¯å²(@neuecc)ã§ã®è©±ã§ããã SelectManyã¨ã¯ã¨ãªæ§æã§Using ãã¿å ãã³ã¼ãå ã¯Code, code and more code.: SelectMany; combining IDisposable and LINQããã static void Main(string[] args) { var firstLines = from path in new[] { "foo.txt", "bar.txt" } from stream in File.OpenRead(path) from reader in new StreamReader(stream) select path + "\t" + reader.ReadLine(); } public static IEnumerable<TR
ããã¨ä¾¿å©ã§ããããã¨ãããã¨ã§æ¸ãã¦ã¿ãã ããããã³ã¼ãã£ã³ã°ãã¿ã¼ã³ã«ã¯ yield ã¨ã使ã£ã¦ãªãã§ãã ãã£ã¡ã®æ¹ãããããããã§ããï¼ Select å ¨ã¦ã®è¦ç´ ã«ä½ããã®å¦çãè¡ãããã¨ãã«ä½¿ç¨ãã¾ãã // ããããã³ã¼ãã£ã³ã°ãã¿ã¼ã³ãã®1 // å ¨ã¦ã®è¦ç´ ã2åããã¡ã½ãã public IEnumerable<int> DoubleAll(int[] target) { var result = new int[target.Length]; for (int i = 0; i < target.Length; i++) { result[i] = target[i] * 2; } return result; } // Selectã§æ¸ãç´ã public IEnumerable<int> DoubleAll(IEnumerable<int> target) { re
ããã°ã©ãã³ã°C# 第6çã8.3.9 è¦ç´ ãå ¨ã¦ä½¿ç¨ãã¦åä¸ã®å¤ãè¿ãããã®æ¼ç®åã§ããä¾ãã°è¦ç´ æ°ãè¿ãCountæ¼ç®åããå ¨ã¦ã®è¦ç´ ã®åè¨å¤ãè¨ç®ããSumãªã©ãããã«ãããã¾ãã using System; using System.Linq; class Program { static void Main() { int[] nums = new int[] {2,4,6,8}; Console.WriteLine("è¦ç´ æ°:{0}", nums.Count() ); Console.WriteLine("åè¨å¤:{0}", nums.Sum() ); } } $ main è¦ç´ æ°:4 åè¨å¤:20ã次ã¯ã¿ã¤ãã«ã«ãããããã«Aggregateæ¼ç®åã«ã¤ãã¦ã§ãã ããã¯æ±ç¨ã®æ¼ç®åã«ãªã£ã¦ãã¦ãã®æ¼ç®åã使ãã°å ¨ã¦ã®éç´ç¨æ¼ç®åã®å¦çãæ¸ããã¨ãåºæ¥ã¾ãã ä¾ã¨ãã¦å ç¨ã®Co
æ¨æ¥ã®è¨äºãæ¸ãä¸ããå¾ãforã®äºéã«ã¼ããã©ããããèãã¦ããã¨ããã以ä¸ã®è¨äºãç®ã«ãã¾ããã Stringã¨StringBuilderã¨ãin C# - äºå²¡çããã°ã©ãæ¥è¨ ãã®ä¸ã§ã«ã¼ãã¯LINQã«ããã¨ããè¨è¼ããããLINQã®ã³ã¼ããã¡ã¢çã«æ®ãã¦ããªãã£ããã¨ããããforã®äºéã«ã¼ããLINQã§æ¸ããªããã¦ã¿ã¾ãã(åããã¦ãstring.Format()é¨åãä¿®æ£)ã â å ã ã®ã½ã¼ã¹ var contents = new List<string>(); for (int row = 1; row < 10000; row++) { var startNo = GetCellValue(row, START_COLUMN); var lastNo = GetCellValue(row, LAST_COLUMN); if (startNo == 0 && lastNo =
ãããã ããªãã¯ã¨ããæ¥åç¨ã¢ããªã±ã¼ã·ã§ã³ã®éçºã»ä¿å®ãä»»ããã¦ãã¾ãã ãã®ã¢ããªã±ã¼ã·ã§ã³ã¯C#ã§è¨è¿°ããã¦ããã ã¨ããä¼æ¥ã«ãããããã¸ã§ã¯ã(Project)ã®ç®¡çã主ç®çã¨ãã¦ãã¾ãã ããã¸ã§ã¯ãã«ã¯ä½åãã®ç¤¾å¡ãã¢ãµã¤ã³ããã¦ãã(AssignedStaffs)ã ããã¸ã§ã¯ãå ã«ã¯å¿ ãããã¼ã¸ã£ã¼ã1ååå¨ãã¾ã(ManagerStaffId)ã 大ã¾ããªã¤ã¡ã¼ã¸ã¨ãã¦ã¯ä»¥ä¸ã®ãããªã³ã¼ãã«ãªã£ã¦ãã¾ã: public class Staff { public String Id {get; set;} public String Name {get; set;} ... } public class Project { public ArrayList AssignedStaffs {get; set;} public String ManagerStaffId {
åé¡ ç¾ããããã°ã©ã ãæ¸ã(è±æ·»åè·äººç·¨) ã§ã¯æ·»åãå¤ç¨ããèªã¿é£ããªã£ã¦ããã½ã¼ã¹ã³ã¼ãã®ãªãã¡ã¯ã¿ãªã³ã°ãéã㦠ç¾ããããã°ã©ã ãæ¸ãããã®ãã¤ã³ããããã¤ãç´¹ä»ãã¾ããã ããã§ã¯ ãä½ããããããåºæºã«ããã°ã©ã ãæ¸ãã¾ãããã ãã©ããããããåé¢ã«åºãããã°ã©ã ã¯æå³ãææ¡ãé£ããªãã¾ããæ·»åãæ示çãªã«ã¼ãã®ä½¿ç¨ã¯é¿ãã¾ãããããã©ããããããåé¢ã«åºã¦ãã¦ãã¾ãã¾ãã ä»æã®ããã°ã©ãã³ã°è¨èªãªãã°ä¾¿å©ãªæ§æãã©ã¤ãã©ãªé¢æ°ãããã®ã§ã æ·»åãã«ã¼ãã使ããã¨ããä½ããããããåºæºã«ããã°ã©ã ãæ¸ãæããªã£ã¦ãã¾ãã ã¨ãããã¨ãè¿°ã¹ã¾ããã 確ãã«ããã£ã¨ããªä¸»å¼µã§ã¯ããã¾ãããçµé¨å¤ã®å°ãªã人ããããã° ããããªãã¨ãè¨ããã¦ãã©ããªã©ã¤ãã©ãªé¢æ°ããã£ã¦ã©ãããå ´é¢ã§ä½¿ããã®ããªãã¡ã¬ã³ã¹ãèªãã§ãããåãããªããâ¦â¦ã ã¨ãããã¨ã¯ããããã¾ãã ã¨ãã訳ã§ã
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}