Click here to Skip to main content
15,921,530 members
Home / Discussions / C#
   

C#

 
AnswerRe: SQL Database Connection Pin
coolestCoder21-Mar-07 18:35
coolestCoder21-Mar-07 18:35 
GeneralRe: SQL Database Connection Pin
Darkness8421-Mar-07 18:40
Darkness8421-Mar-07 18:40 
GeneralRe: SQL Database Connection Pin
coolestCoder21-Mar-07 19:15
coolestCoder21-Mar-07 19:15 
GeneralRe: SQL Database Connection Pin
Darkness8421-Mar-07 19:20
Darkness8421-Mar-07 19:20 
QuestionRe: Calculate and Display Prime Numbers Pin
chitra4sat21-Mar-07 18:05
chitra4sat21-Mar-07 18:05 
AnswerRe: Calculate and Display Prime Numbers Pin
sherifffruitfly21-Mar-07 18:11
sherifffruitfly21-Mar-07 18:11 
AnswerRe: Calculate and Display Prime Numbers Pin
Leslie Sanford21-Mar-07 18:33
Leslie Sanford21-Mar-07 18:33 
GeneralRe: Calculate and Display Prime Numbers Pin
chitra4sat21-Mar-07 19:27
chitra4sat21-Mar-07 19:27 
Thanks Guyz,

I have tried it as this but the problem is i have to put all the methods in a another class progam such as PrimeNumClass.cs and i have to call that in the main program to display the output.

here is my code:
<br />
namespace PrimeNumber<br />
{<br />
    class Program<br />
    {<br />
        static void Main(string[] args)<br />
        {<br />
            // declare variables<br />
            int n = 2;<br />
            int totalPrimeNumbers = 0;<br />
            int x;<br />
            double sumOfPrimes = 0;<br />
<br />
            // while loop when n <= 100<br />
            while (n <= 100)<br />
            {<br />
                bool isPrime = true;<br />
<br />
                // test if n is prime<br />
                for (x = 2; x < n; x++)<br />
                {<br />
                    if ((n % x) == 0)<br />
                    {<br />
                        isPrime = false;<br />
                        break;<br />
                    }<br />
                }<br />
<br />
                if (isPrime == true)<br />
                {<br />
                    Console.WriteLine(n + " is a prime Number.");<br />
<br />
                    sumOfPrimes = sumOfPrimes + n;<br />
                    totalPrimeNumbers++;<br />
                }<br />
                n++;<br />
            }<br />
           <br />
<br />
        }<br />
    }<br />
}<br />


Here everything is in Main Program itself. But i want it all in a seperate class Nmaed PrimeNumClass.cs and i have to call that class in the main Class to display the output.

please help me. itz very urgnet.

regards,

Chitra
GeneralRe: Calculate and Display Prime Numbers Pin
Leslie Sanford21-Mar-07 19:37
Leslie Sanford21-Mar-07 19:37 
GeneralRe: Calculate and Display Prime Numbers Pin
chitra4sat21-Mar-07 19:48
chitra4sat21-Mar-07 19:48 
GeneralRe: Calculate and Display Prime Numbers Pin
Leslie Sanford21-Mar-07 20:00
Leslie Sanford21-Mar-07 20:00 
QuestionC# Automation Addin for Excel using ,NET - Build Error - Cannot Register Assembly (MSB3217) Pin
ralph_y21-Mar-07 17:58
ralph_y21-Mar-07 17:58 
QuestionHow to remove the rectangle from Propertygrid ? Pin
TaiZhong21-Mar-07 17:03
TaiZhong21-Mar-07 17:03 
AnswerRe: How to remove the rectangle from Propertygrid ? Pin
visualhint16-Apr-07 3:33
visualhint16-Apr-07 3:33 
Questionblock website function by enterring in texbox in a form.need help here Pin
krajah1021-Mar-07 15:26
krajah1021-Mar-07 15:26 
Questionthread question Pin
dino209421-Mar-07 14:51
dino209421-Mar-07 14:51 
AnswerRe: thread question Pin
Leslie Sanford21-Mar-07 17:02
Leslie Sanford21-Mar-07 17:02 
QuestionProgram structure need experienced programmers perspective please Pin
Mischievious21-Mar-07 14:36
Mischievious21-Mar-07 14:36 
AnswerRe: Program structure need experienced programmers perspective please Pin
Leslie Sanford21-Mar-07 17:05
Leslie Sanford21-Mar-07 17:05 
GeneralRe: Program structure need experienced programmers perspective please Pin
Mischievious21-Mar-07 18:14
Mischievious21-Mar-07 18:14 
QuestionQuestion about Windows Media Encoder Pin
Julianne_juju21-Mar-07 14:11
Julianne_juju21-Mar-07 14:11 
QuestionNeed help with XML config file Pin
Mark F.21-Mar-07 13:40
Mark F.21-Mar-07 13:40 
AnswerRe: Need help with XML config file Pin
coolestCoder21-Mar-07 18:31
coolestCoder21-Mar-07 18:31 
QuestionTrouble converting byte[] to bmp..... Pin
Are Jay21-Mar-07 12:17
Are Jay21-Mar-07 12:17 
AnswerRe: Trouble converting byte[] to bmp..... Pin
Nick Hodapp21-Mar-07 12:44
sitebuilderNick Hodapp21-Mar-07 12:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.