Click here to Skip to main content
15,346,923 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is there a better way in Rx? Pin
Kenneth Haugland21-Mar-16 7:47
mvaKenneth Haugland21-Mar-16 7:47 
GeneralRe: Is there a better way in Rx? Pin
Matt T Heffron21-Mar-16 9:53
professionalMatt T Heffron21-Mar-16 9:53 
GeneralRe: Is there a better way in Rx? Pin
Matt T Heffron21-Mar-16 7:10
professionalMatt T Heffron21-Mar-16 7:10 
QuestionX Number Of Results Per Line Pin
MadDashCoder18-Mar-16 11:16
MemberMadDashCoder18-Mar-16 11:16 
QuestionRe: X Number Of Results Per Line Pin
CHill6018-Mar-16 11:50
mveCHill6018-Mar-16 11:50 
AnswerRe: X Number Of Results Per Line Pin
MadDashCoder18-Mar-16 12:44
MemberMadDashCoder18-Mar-16 12:44 
AnswerRe: X Number Of Results Per Line Pin
Richard Andrew x6418-Mar-16 12:42
professionalRichard Andrew x6418-Mar-16 12:42 
AnswerRe: X Number Of Results Per Line Pin
Sascha Lefèvre18-Mar-16 14:45
professionalSascha Lefèvre18-Mar-16 14:45 
You didn't ask for this but maybe you'll find it interesting - I got a bit carried away..
C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace OddNumbers
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteNumbers(EvenNumbers(100, 1000), 10);
            Console.ReadKey();

            WriteNumbers(OddNumbers(100, 1000), 10);
            Console.ReadKey();
        }

        static void WriteNumbers(IEnumerable<int> numbers, int numbersPerLine)
        {
            Debug.Assert(numbers != null);
            Debug.Assert(numbersPerLine >= 1);

            StringBuilder line = new StringBuilder();
            int count = 0;

            Action writeLine = () =>
            {
                Console.WriteLine(line.ToString());
                line.Clear();
                count = 0;
            };

            foreach (int number in numbers)
            {
                line.Append(number).Append(", ");

                count++;

                if (count == numbersPerLine)
                    writeLine();
            }

            if (count > 0)
                writeLine();
        }

        static IEnumerable<int> EvenNumbers(int start, int end)
        {
            Debug.Assert(start <= end);

            if (IsOdd(start))
                start++;

            for (int i = start; i <= end; i += 2)
                yield return i;
        }

        static IEnumerable<int> OddNumbers(int start, int end)
        {
            Debug.Assert(start <= end);

            if (!IsOdd(start))
                start++;

            for (int i = start; i <= end; i += 2)
                yield return i;
        }

        static bool IsOdd(int number)
        {
            return (number & 1) == 1;
        }
    }
}

If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: X Number Of Results Per Line Pin
Brisingr Aerowing18-Mar-16 15:08
professionalBrisingr Aerowing18-Mar-16 15:08 
GeneralRe: X Number Of Results Per Line Pin
Luc Pattyn19-Mar-16 14:12
sitebuilderLuc Pattyn19-Mar-16 14:12 
GeneralRe: X Number Of Results Per Line Pin
Brisingr Aerowing19-Mar-16 20:30
professionalBrisingr Aerowing19-Mar-16 20:30 
AnswerRe: X Number Of Results Per Line Pin
Richard Deeming21-Mar-16 2:50
mveRichard Deeming21-Mar-16 2:50 
QuestionSocket closing without FIN from peer Pin
MidwestLimey17-Mar-16 9:39
professionalMidwestLimey17-Mar-16 9:39 
AnswerRe: Socket closing without FIN from peer Pin
Fueled By Decaff18-Mar-16 3:52
MemberFueled By Decaff18-Mar-16 3:52 
GeneralRe: Socket closing without FIN from peer Pin
MidwestLimey18-Mar-16 14:17
professionalMidwestLimey18-Mar-16 14:17 
QuestionHow can i create a dialog box window in asp.net C# (web) which contains many field? Pin
Hameed Khan17-Mar-16 5:35
MemberHameed Khan17-Mar-16 5:35 
AnswerRe: How can i create a dialog box window in asp.net C# (web) which contains many field? Pin
OriginalGriff17-Mar-16 6:28
mveOriginalGriff17-Mar-16 6:28 
SuggestionRe: How can i create a dialog box window in asp.net C# (web) which contains many field? Pin
Richard Deeming17-Mar-16 6:58
mveRichard Deeming17-Mar-16 6:58 
GeneralRe: How can i create a dialog box window in asp.net C# (web) which contains many field? Pin
OriginalGriff17-Mar-16 7:10
mveOriginalGriff17-Mar-16 7:10 
QuestionRe: How can i create a dialog box window in asp.net C# (web) which contains many field? Pin
ZurdoDev17-Mar-16 10:15
professionalZurdoDev17-Mar-16 10:15 
AnswerRe: How can i create a dialog box window in asp.net C# (web) which contains many field? Pin
F-ES Sitecore18-Mar-16 0:37
professionalF-ES Sitecore18-Mar-16 0:37 
QuestionTime Elapse Pin
Aelmfr16-Mar-16 13:57
MemberAelmfr16-Mar-16 13:57 
AnswerRe: Time Elapse Pin
Garth J Lancaster16-Mar-16 14:30
professionalGarth J Lancaster16-Mar-16 14:30 
GeneralRe: Time Elapse Pin
Aelmfr16-Mar-16 14:46
MemberAelmfr16-Mar-16 14:46 
AnswerRe: Time Elapse Pin
Patrice T16-Mar-16 14:37
mvePatrice T16-Mar-16 14:37 

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.