using System;
using System.Collections;
const int LAST_CANDIDATE = 1000;
int primes = 0;
BitArray candidates = new BitArray (LAST_CANDIDATE, true);
for (int i = 2; i < LAST_CANDIDATE; i++)
{
if (candidates[i])
{
for (int j = i * 2; j < LAST_CANDIDATE; j += i)
{ candidates[j] = false; }
}
}
for (int i = 1; i < LAST_CANDIDATE; i++)
{
if (candidates[i])
{
primes++;
Console.Out.WriteLine (i);
}
}
Console.Out.WriteLine
("\n" + primes + " primes found in the range 2-" + LAST_CANDIDATE);
Search
Calculate prime numbers
This C# code snippet uses a BitArray to calculate the prime numbers over then range 2-n.
Application Framework in 12 steps
An application framework is a software library that provides a fundamental structure to support the development of applications for a specific environment. An application framework acts as the skeletal support to build an application. The intention of designing application frameworks is to lessen the general issues faced during the development of applications. This is achieved through the use of code that can be shared across different modules of an application. Application frameworks are used not only in the graphical user interface (GUI) development, but also in other areas like web-based applications.
Application frameworks are not a recently emerged idea. Some of the old application frameworks that are still used today are the SmallTalk user interface framework, MacApp (for Macintosh), and Struts (for Web-based Java applications).
We can start with the interface to define a signature
The Abstract calss
The sealed class
A lazy port scanner written in c#
This is a legacy port scanner to scan all the open ports over an IP address written in c#
Subscribe to:
Posts
(
Atom
)