Click here to Skip to main content
15,922,512 members
Home / Discussions / C#
   

C#

 
AnswerRe: Please explain me this small piece of code... Pin
Luc Pattyn24-Aug-07 13:15
sitebuilderLuc Pattyn24-Aug-07 13:15 
GeneralRe: Please explain me this small piece of code... Pin
George L. Jackson24-Aug-07 13:41
George L. Jackson24-Aug-07 13:41 
GeneralRe: Please explain me this small piece of code... Pin
PIEBALDconsult24-Aug-07 18:59
mvePIEBALDconsult24-Aug-07 18:59 
GeneralRe: Please explain me this small piece of code... Pin
George L. Jackson25-Aug-07 1:29
George L. Jackson25-Aug-07 1:29 
AnswerRe: Please explain me this small piece of code... Pin
George L. Jackson24-Aug-07 13:37
George L. Jackson24-Aug-07 13:37 
AnswerRe: Please explain me this small piece of code... Pin
PIEBALDconsult24-Aug-07 19:17
mvePIEBALDconsult24-Aug-07 19:17 
GeneralRe: Please explain me this small piece of code... Pin
George L. Jackson25-Aug-07 2:16
George L. Jackson25-Aug-07 2:16 
QuestionI need a full stop Pin
humayunlalzad24-Aug-07 11:12
humayunlalzad24-Aug-07 11:12 
I want that after the last no. I should get a fullstop and not a comma.
Pl somebody correct my code for me.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ch11Ex03yield
{
    public class Primes 
    {
        private long min;
        public  long max;

        public Primes()
            : this(2, 100)
        {
        }

        public Primes(long i, long j)
        {
            if (i < 2)
            {
                min = 2;
            }
            min = i;
            max = j;
        }
        public IEnumerator GetEnumerator()
        {
            for (long possiblePrime = min; possiblePrime <= max; possiblePrime++)
            {
                bool isPrime = true;
                for (long possibleFactor = 2; possibleFactor <=
                    (long)Math.Floor(Math.Sqrt(possiblePrime)); possibleFactor++)
                {
                    long remainderAfterDivision = possiblePrime % possibleFactor;
                    if (remainderAfterDivision == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }
                if (isPrime)
                {
                    yield return possiblePrime;
                }
            }
        }
    }
                        
    class Program
    {
        static void Main(string[] args)
        {
            Primes myPrimes = new Primes(2,1000);
            foreach (long i in myPrimes)
                Console.Write("{0}{1} ",i,
                    (i==myPrimes.max )?".":",");
            
            Console.ReadKey();
        }
    }
}

AnswerRe: I need a full stop Pin
Michael Potter24-Aug-07 11:45
Michael Potter24-Aug-07 11:45 
AnswerRe: I need a full stop Pin
Christian Graus24-Aug-07 11:46
protectorChristian Graus24-Aug-07 11:46 
AnswerRe: I need a full stop Pin
PIEBALDconsult24-Aug-07 11:59
mvePIEBALDconsult24-Aug-07 11:59 
GeneralRe: I need a full stop Pin
Christian Graus24-Aug-07 12:01
protectorChristian Graus24-Aug-07 12:01 
AnswerRe: I need a full stop Pin
PhilipPainter27-Aug-07 11:48
PhilipPainter27-Aug-07 11:48 
QuestionNew to C# Programming Pin
invalidsyntax101024-Aug-07 9:53
invalidsyntax101024-Aug-07 9:53 
AnswerRe: New to C# Programming [modified] Pin
Dio2224-Aug-07 10:04
Dio2224-Aug-07 10:04 
AnswerRe: New to C# Programming Pin
PIEBALDconsult24-Aug-07 10:26
mvePIEBALDconsult24-Aug-07 10:26 
GeneralRe: New to C# Programming Pin
Christian Graus24-Aug-07 11:47
protectorChristian Graus24-Aug-07 11:47 
AnswerRe: New to C# Programming Pin
ghle24-Aug-07 11:04
ghle24-Aug-07 11:04 
AnswerRe: New to C# Programming Pin
humayunlalzad24-Aug-07 11:19
humayunlalzad24-Aug-07 11:19 
GeneralRe: New to C# Programming Pin
Colin Angus Mackay24-Aug-07 14:19
Colin Angus Mackay24-Aug-07 14:19 
AnswerRe: New to C# Programming Pin
Christian Graus24-Aug-07 11:47
protectorChristian Graus24-Aug-07 11:47 
GeneralRe: New to C# Programming Pin
invalidsyntax101024-Aug-07 12:05
invalidsyntax101024-Aug-07 12:05 
GeneralRe: New to C# Programming Pin
ChrisKo24-Aug-07 12:56
ChrisKo24-Aug-07 12:56 
AnswerRe: New to C# Programming Pin
Luc Pattyn24-Aug-07 13:28
sitebuilderLuc Pattyn24-Aug-07 13:28 
AnswerRe: New to C# Programming Pin
George L. Jackson24-Aug-07 14:02
George L. Jackson24-Aug-07 14:02 

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.