Questions tagged [console.writeline]

Writes the specified data, followed by the current line terminator, to the standard output stream.

Writes the specified data, followed by the current line terminator, to the standard output stream.

253 questions
-1
votes
1 answer

While will not end after user enters

Everything runs fine. However, I need the loop to end contingent upon how many numbers the user enters in the first question. using System; namespace Looping { class Program { static void Main(string[] args) { …
user18292265
-1
votes
1 answer

showing memory addresses with Console.Writeline

I have this code in a c# console application: int x = 10; int* ptr1 = &x; Console.WriteLine((int)ptr1); Console.WriteLine((long)ptr1); Console.WriteLine((ulong)ptr1); Why do I get a diferente value for the int datatype? Is it because of the…
gtpt
  • 113
  • 7
-1
votes
1 answer

Method not Printing?

So I'm currently working on a project for my C# class where we have to recreate Minesweeper using the Console. I'm fairly new to C# but have worked with other code languages before so I've been able to sort out most problems. The newest one i'm…
-1
votes
1 answer

Why do I keep getting a System.IndexOutOfRangeException at my Console.WriteLine(", '{0}'", String); statement?

I'm working on a web crawler in C# in Visual Studio that reads URLs from an Excel spreadsheet into an array of strings that will be gone through later to visit sites to scrape information from. I am debugging it right now, but for some reason I get…
-1
votes
2 answers

Write a list in a single line in C#

If I have a list var myList = new List(); and I add a couple of strings myList.Add("Hello"); myList.Add("World"); myList.Add("!"); How do I print the entire list on one line? If I try Console.WriteLine(myList); the console prints…
Erik Norberg
  • 53
  • 2
  • 7
-1
votes
1 answer

Program ending in the middle of being ran

using System; using System.Collections.Generic; namespace Learning_C__Program { class Program { static void Main(string[] args) { int enemyHealth = 1000; int playerHealth = 1000; string[]…
-1
votes
3 answers

C# Switch Case with if statements not returning me the console.WriteLines

I am trying to create a simple switch case with If-Statements code. Problem: I don't get any value back. For Example: If I put int Temperature = 0; the Code should output "Es ist kalt". But my console doesn't display anything. using…
-1
votes
1 answer

C# Console.WriteLine()

So, I wrote this code to run string values in a json file and determine if it is a palindrome or not. I am having trouble displaying the results in the console correctly. My Console.WriteLine is the issue (i think). It displays the true/false…
idkidk
  • 61
  • 5
-1
votes
1 answer

Handling Exceptions (Null?) in Console.Writeline content

There has to be a better way to do this?! I was messing around with ?. etc but could not figure out the proper context for it. I need to add several more items to the console output, so adding several more nested try-catch is daunting yet do-able.…
David Elgstuen
  • 153
  • 2
  • 7
-1
votes
1 answer

C# WriteLine method shows numbers inside brackets instead of what I want the to be replaced with

I just started learning C# and this is my code of a simple program for homework: using System; namespace Concatenate_Data { class Program { static void Main(string[] args) { string firstName =…
-1
votes
2 answers

I can't take marks for other subjects except for maths in C#

I have a c# code below. This code takes the name, marks for maths, computer, science, environment and History from the user and prints the total and percentage. The problem with this code is that it takes only the marks from maths. And it prints the…
-1
votes
1 answer

Create new lines in output text - Python

I'm writing a code in Python IDLE 3.6 that prints out a user's name in their own choice of style and colour and everything is working fine apart from this. Somehow it won't print out the three highlighted lines underneath each other and I've tried…
Hana
  • 1
  • 2
-1
votes
1 answer

Console WriteLine while waiting for console ReadLine

I have a console app that is running multiple worker threads. I would like the console output to have one WriteLine to report the status of each thread. I know I can simply clear, and loop through my threads to report their status on some interval,…
Roger
  • 2,063
  • 4
  • 32
  • 65
-1
votes
1 answer

Printing out current state of separate threads in Console application c#

I have a code which basically looks like this: Parallel.Foreach(items,dbItem=> { int counter = 0; Interlocked.Increment(ref counter); Console.WriteLine("Current counter state: " + counter); }); What I would like to do here is to simple…
User987
  • 3,663
  • 15
  • 54
  • 115
-1
votes
2 answers

c# Splitting a string into columns using console

I have to get strings out of a text file and save them to a list. For each line I should write down the outcomes written in columns perfectly sorted under each other. I have to write every line given in the text file down in the console. I have a…