⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 17.8.htm

📁 This ECMA Standard specifies the form and establishes the interpretation of programs written in the
💻 HTM
📖 第 1 页 / 共 2 页
字号:
   static int Count(int max) {  
      BitArray flags = new BitArray(max + 1);  
      int count = 1;  
      for (int i = 2; i <= max; i++) {  
         if (!flags[i]) {  
            for (int j = i * 2; j <= max; j += i) flags[j] = true;  
            count++;  
         }  
      }  
      return count;  
   }  
   static void Main(string[] args) {  
      int max = int.Parse(args[0]);  
      int count = Count(max);  
      Console.WriteLine("Found {0} primes between 1 and {1}", count,  
      max);  
   }  
}  
</pre></span></span><span class="paragraph"><span class="example">Note that the syntax for accessing elements of the BitArray is precisely the same as for a bool[]. end example]</span> </span><span class="paragraph"><span class="example">[Example: The following example shows a 26&#215;10 grid class that has an indexer with two parameters. The first parameter is required to be an  upper-or lowercase letter in the range A-Z, and the second is required to be an integer in the range 0-9. <pre class="code-example">
using System;  
class Grid  
{  
   const int NumRows = 26;  
   const int NumCols = 10;  
   int[,] cells = new int[NumRows, NumCols];  
   
   public int this[char c, int colm]  
   {  
      get {  
         c = Char.ToUpper(c);  
         if (c &lt; 'A' || c &gt; 'Z') {  
            throw new ArgumentException();  
         }  
         if (colm &lt; 0 || colm &gt;= NumCols) {  
            throw new IndexOutOfRangeException();  
         }  
         return cells[c - 'A', colm];  
      }  
      set {  
         c = Char.ToUpper(c);  
         if (c &lt; 'A' || c &gt; 'Z') {  
            throw new ArgumentException();  
         }  
         if (colm &lt; 0 || colm &gt;= NumCols) {  
            throw new IndexOutOfRangeException();  
         }  
         cells[c - 'A', colm] = value;  
      }  
   }  
}  
</pre>end example]</span> </span><span class="ruler"></span><table><tr><td><table align="left" bgcolor="navy"><tr bgcolor="navy"><td><font face="Arial,sans-serif" size="6" color="yellow"><strong>{ JSL }</strong></font></td></tr></table></td></tr><tr><td><font face="Arial,sans-serif" size="2" color="navy"><strong>Jagger Software Ltd</strong></font></td></tr><tr><td><font face="Arial,sans-serif" size="2" color="navy"><strong>Company # 4070126</strong></font></td></tr><tr><td><font face="Arial,sans-serif" size="2" color="navy"><strong>VAT # 762 5213 42</strong></font></td></tr></table><img src="valid-html401.png" align="left" height="31" width="88" alt="Valid HTML 4.01" /><img src="vcss.gif" align="left" height="31" width="88" alt="Valid CSS" /></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -