not really a Monogame question, but still

EDIT: I guess this is a visual studio problem. I commented out every part of the code and it still happened… am I crazy?

So I’ve found a new way to embarrass myself with a basic question, but I don’t know what’s going on here. Also, if someone could tell me how to format the text in this forum, I would appreciate it.

‘’’
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Euler._1_50
{
class Prime1
{
public Prime1()
{
Console.WriteLine(“What is your uppper limit in searching for prime numbers?”);
int limit = Console.Read();

        List<bool> isPrime = new List<bool>();

        for (int i = 0; i <= limit; i++)
        {
            isPrime.Add(true);
        }
        for (int i = 0; i <= limit; i++)
        {
            Console.WriteLine(isPrime[i]);
        }
        Console.Read();
    }
}

}
‘’’

My goal is to eventually make a program that finds all primes within a given integer value. At this point, I just want get a bounds for a list and then print the true false (all true) values within that list. I see it happening as intended, but then it instantly shuts down with this in the debug window. wutmydoinwrong?

‘’’
‘Euler.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.

‘Euler.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘c:\users\tracer\source\repos\Euler\Euler\bin\Debug\Euler.exe’. Symbols loaded.

The program ‘[11292] Euler.exe’ has exited with code 0 (0x0).
‘’’

Use a while loop at the end its detecting your keypress so fast its both running the program and exiting before you can lift your finger.

When editing your post highlight your code by clicking and holding as you move over the text.
Then press the preformated text button after what you want as code is highlighted.
Sometimes you have to click it a couple times.

Im not sure its ok to put . or period’s if you will in namespaces.

hope this isn’t homework, if so i would rewrite that, determine prime method, the rest is fair advice.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Euler_150
{
class Program
{
    static void Main(string[] args)
    {
        Prime1 p = new Prime1();
        p.ExecutePrimeDirective();
    }
}

public class Prime1
{
    public void ExecutePrimeDirective()
    {
        string endstring = "";
        while (endstring != "e")
        {
            Console.WriteLine("\n What is your uppper limit in searching for prime numbers?");
            string numberstring = Console.ReadLine();

            int limit = 0;
            int test = 0;
            if (int.TryParse(numberstring, out test))
                limit = test;
            else // the else is not required it's left in for clarity
                limit = 0;

            List<bool> isPrime = new List<bool>();

            for (int i = 0; i <= limit; i++)
            {
                if (DeterminePrime(i))
                    isPrime.Add(true);
                else
                    isPrime.Add(false);
            }
            for (int i = 0; i <= limit; i++)
            {
                Console.WriteLine("isPrime[" + i.ToString()+"]  " + isPrime[i]);
            }

            while (endstring != "e" && endstring != "r")
            {
                Console.WriteLine("\n Type >>> e <<< and press enter to exit \n Type >>> r <<< to restart and try again");
                endstring = Console.ReadLine();
            }
        }
    }
    // i just copy pasted this part
    public bool DeterminePrime(int number)
    {
        return (Enumerable.Range(1, number).Where(x => number % x == 0).Count() == 2);
    }
}
}

“ReadLine”

…I’m so mad.

use this
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Euler
{
class Program
{
static void Main(string[] args)
{
Prime p = new Prime();
p.ExecutePrimeDirective();
}
}

public class Prime
{
public void ExecutePrimeDirective()
{
string endstring = “”;
while (endstring != “e”)
{
Console.WriteLine("\n What is your uppper limit in searching for prime numbers?");
string numberstring = Console.ReadLine();

        int limit = 0;
        int test = 0;
        if (int.TryParse(numberstring, out test))
            limit = test;
        else // the else is not required it's left in for clarity
            limit = 0;

        List<bool> isPrime = new List<bool>();

        for (int i = 0; i <= limit; i++)
        {
            if (DeterminePrime(i))
                isPrime.Add(true);
            else
                isPrime.Add(false);
        }
        for (int i = 0; i <= limit; i++)
        {
            Console.WriteLine("isPrime[" + i.ToString()+"]  " + isPrime[i]);
        }

        while (endstring != "e" && endstring != "r")
        {
            Console.WriteLine("\n Type >>> e <<< and press enter to exit \n Type >>> r <<< to restart and try again");
            endstring = Console.ReadLine();
        }
    }
}
// i just copy pasted this part
public bool DeterminePrime(int number)
{
    return (Enumerable.Range(1, number).Where(x => number % x == 0).Count() == 2);
}

}
}
xbox customer service