Questions tagged [console.writeline]
Writes the specified data, followed by the current line terminator, to the standard output stream.
245
questions
32
votes
2
answers
4k
views
What is the rounding rule when the last digit is 5 in .NET?
Here is my code:
using static System.Console;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
double[] doubles = new[] { 9.05, 9....
0
votes
0
answers
28
views
~ no response on stdout ~ C# Error while submitting code in HackerRank
I am practicing C# code on HackerRank online website, when I want to submit my code then it gives an error:
Below is my code:
for(int i=0;i<input.Count-1;i++){
string evenData="",...
-3
votes
2
answers
51
views
With only one console writeline, how can I give multiple console writelines?
There are multiple Console.WriteLine() arguments between some values, but I don't want to give them all separately by copypaste, is there any way I can specify the number of WriteLine arguments with ...
0
votes
1
answer
46
views
Each time for loop repeats print different console.WriteLine
Everything runs perfectly. If a user enters more than one to repeat the first for loop I want the question to say "Please enter number 2" and so forth. Is there way to do this within the ...
-1
votes
1
answer
22
views
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 ...
1
vote
0
answers
119
views
How to make MSTest grab all console output from unit test? Output behind WebHost.CreateDefaultBuilder() goes missing (VS2022, .NET 6, MSTest 2.2.10)
I'm creating an integration test for a Web API, so I'm starting an entire application in a unit test using WebHost.CreateDefaultBuilder() and the usual setup bits.
While unit testing, my log framework ...
-2
votes
7
answers
2k
views
How write python to Read the first two lines from a text file named "file1.txt" Write the two lines read from "file1.txt" to a new file "file2.txt"
Read the first two lines from a text file named "file1.txt" Write the two lines read from "file1.txt" to a new file "file2.txt"
-1
votes
1
answer
51
views
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 ...
-2
votes
1
answer
53
views
Combining two Console.WriteLine(); public static voids [closed]
I am new to C# so this might be really dumb and I am doing it all wrong but... I am trying to write a text adventure and I need to be able to slow type each letter out and wrap each word to 80 chars, ...
1
vote
1
answer
96
views
Console.WriteLine Doesn't Support Turkish Characters In Dotnet Web Api Application
In console app:
Console.WriteLine("şşşşşşşşşşşşşşşşşşş");
Output shows me in a correct way but when I write the same code line in dotnet web api
Output:
ÄŸÄŸÄŸÄŸÅŸÅŸÅŸÅŸÅŸ
What I've tried ...
0
votes
1
answer
52
views
How to print internet search outputs to visual studio console in C#?
So I am working on a c# program which is intended to perform a random Google Search every random time between 1 and 100 minutes. However, when running the program, I am noticing the CPU usage never ...
0
votes
1
answer
54
views
Applying grammar to strings
I'm trying to make the genetive of the inserted name be decided automatically so that I won't have to manually insert the proper genetive for each string (in this case names)
As an example the ...
0
votes
2
answers
41
views
Console doesnt display but the first row
We are trying to write 3 arrays on console
like this;
DDDEEDUDE
EDUDEU
DUUEUEDD
randomly selecting arrays and letters
code given runs completely fine but it doesn't display but the first line.
I ...
0
votes
3
answers
67
views
In a C# console app, can you make one part of a message one color, and a different part another color?
I want to print to the console a message with multiple colors.
For example:
(red) error: (white) command not found
Is this possible?
1
vote
2
answers
232
views
How to print a double using Console.WriteLine in C#
public class Account
{
private double balance;
public Account(double initBalance)
{
balance = initBalance;
this.balance = balance;
}
...
0
votes
0
answers
57
views
StreamReader.WriteLine doesn't work after initial Post unity
Im working with the AWS S3 SDK for Unity and I want to send data to a .txt file on a server. (Ideally I'd like it to overwrite with the most recent data I send)
I opened up the S3 demo scene and got ...
0
votes
1
answer
78
views
Python writing to file failure
I am having a bit of a difficulty with writing to file. The setup is that I have some data in one file. It has some integers, single words, sentences (like addresses and such), decimals and other (for ...
-1
votes
1
answer
48
views
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 ...
-3
votes
4
answers
161
views
How to convert For Loop results into an Array then count the integers of the resulting Array in C#?
In C#, how would I go about converting the result of a For Loop into an Array and count (Display on the Console) the number of integers stored in that converted array?
Please see below for what I have ...
0
votes
1
answer
47
views
Message Handler Stops Seeing Responses?
As a workaround for a dumb issue, I have a separate application do my SharePoint file syncing that I launch as a separate process and communicate via WriteLine and ReadLine. After the third Sync ...
0
votes
1
answer
134
views
Unable to use Console.WriteLine(); from a method [duplicate]
I am New to C# and I'm having some trouble with Console.WriteLine(); Method.
using System;
namespace ConsoleApp
{
class Program
{
public static void Main(string[] args)
{
...
0
votes
0
answers
99
views
.Net Console.WriteLine and System.Diagnostics.Debug.WriteLine(); not working
In my .Net MVC 5 project all of my Console.WriteLine statements have simultaneously stopped working. I am in Debug mode (not release) and so is my output window (pics for proof):
However when I run ...
0
votes
1
answer
226
views
VS 2019 Console.WriteLine() versus System.Diagnostics.Debug.WriteLine()
In Visual Studio 2019 I'm unable to get System.Diagnostics.Debug.WriteLine() to show anything in either the Output(Debug) windown nor the Immediate Window. I've got my options settings for 'Debugging-...
0
votes
2
answers
95
views
Console not writing class object name [closed]
C# in Visual Studio... very simple main and class method. When running, my program only reads out "Hi friend", and not "Otis". Any ideas to what's going on?
using System;
...
2
votes
0
answers
56
views
Esc input cuts of Writeline
So I tried to code an userinput with ConsoleKeyInfo. Its works. Than I tried to implement an cancellation when Esc is pressed. It works aswell but it cuts off some of my Writeline. When I try the same ...
-2
votes
1
answer
64
views
why does the first column remain empty on console window in c#
I'm running a simple code to print numbers from 100 to 1:
for (int i = 100; i > 0; i--)
{
Console.Write(i + "\t");
}
in the console window the first row is printed fine. but the other ...
0
votes
2
answers
45
views
I cannot let the list write in txt (python)
I want to use writelines() to let the list write in txt, but after running, there's nothing in my txt. What's wrong with my code?
Help me if you could. Thank you!
example list(records): [['flower', '...
0
votes
2
answers
43
views
Only state once
I am making an RPG sort of text adventure in Visual Studio C# console.
I am trying to create a piece of code that will detect your location. I want it to then respond in the necessary format. I know ...
0
votes
1
answer
403
views
How to display float values in c#? [duplicate]
I'm working with structs in c#, and when I want to display average grade of a student like "4.53", it prints "453". Here's the code:
using System;
using System.Buffers;
namespace ...
-1
votes
1
answer
139
views
Why do I keep getting a System.IndexOutOfRangeException at my Console.WriteLine(", '{0}'", String); statement? [closed]
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 ...
-2
votes
2
answers
148
views
Print values of ArrayList instead of classname [duplicate]
I'd like to print all ten random generated points for each object in the ArrayList AL.
public class Point
{
public int x;
public int y;
public Point(int x, int y)
...
0
votes
1
answer
126
views
Writing values from dictionary object to text file only writing last key value pair
I don't know C# or any programming that well at all, but I want to learn. I've been searching online last couple days to put together what is supposed to read from 2 text files and output a file (...
-1
votes
2
answers
2k
views
Write a list in a single line in C# [duplicate]
If I have a list
var myList = new List<string>();
and I add a couple of strings
myList.Add("Hello");
myList.Add("World");
myList.Add("!");
How do I print the ...
-1
votes
1
answer
37
views
Program ending in the middle of being ran [closed]
using System;
using System.Collections.Generic;
namespace Learning_C__Program
{
class Program
{
static void Main(string[] args)
{
int enemyHealth = 1000;
...
0
votes
2
answers
50
views
Trying to understand variables and basic console commands
I am working through a basic lesson from Solo Learn and have been messing around with variables. I am trying to figure out how calling strings works and have two simple sequences of code. The first ...
0
votes
0
answers
79
views
C# Console.Write shows nothing VS Studio, how to System.Out.Println [duplicate]
Question:
What's the equivalent of System.Out.Println() in C# ?
How to output something to vs IDE terminal?
Expect:
Console.WriteLine() should does the same. But it didn't in WPF project.
Tried ...
0
votes
2
answers
66
views
Can console.writelines handle anonymous object directly? [duplicate]
I want to figure out why "Console.WriteLine(x)" below can directly print the object of a anonymous object?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ...
-1
votes
1
answer
2k
views
How to print my name 100 times without any looping using C#? [closed]
How I can print my name 100 times without using loops in C#? Any clues?
I have already tried to print number 1 to 100 without using loops but how I can do it with string(my name)?
Thank you in ...
-1
votes
3
answers
219
views
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 ...
-2
votes
2
answers
555
views
Why can't you put Console.ReadKey() in front of the text displayed to the console, or assign Console.ReadKey() to a variable?
using System;
class MainClass {
public static void Main (string[] args) {
Console.WriteLine("Press any key to continue...");
Console.WriteLine(" key pressed", Console....
-1
votes
1
answer
85
views
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 ...
2
votes
2
answers
239
views
How to handle overlapping Console.Writeline()'s from fired Event?
Hey i am programming a RDP Bruteforce Protection program for a windows server i own, which even gets attacked after changing the RDP port :/
But i already suffer from logging in console, when there ...
0
votes
1
answer
48
views
How do I get the matrix to print what i intended
I have a question regarding the output of my code. I input numbers 1 through 12 and I expected it to show
1 2 3 |7 8 9
4 5 6 |10 11 12
but its showing
1 2 3| 4 5 6
7 8 9| 10 11 12
Can ...
1
vote
1
answer
105
views
Why is the speed of Console.WriteLine more inconsistent than Debug.WriteLine?
This code outputs almost all 0's with an occasional output of 3-5.
For i As Integer = 1 To 1000
Dim Watch As Stopwatch = Stopwatch.StartNew()
Debug.WriteLine(Watch.ElapsedMilliseconds & " ...
-4
votes
2
answers
415
views
c# Console.WriteLine();
In C#, after I write Console.WriteLine() and I'm asked to enter several values, can I get them all in one method? For example:
double a, b, c = 0;
Console.WriteLine("please enter the values of:\n a ...
-1
votes
1
answer
108
views
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 ...
2
votes
0
answers
153
views
How do I print from a jagged array?
I just got onto the topic of Jagged Arrays, and im testing out one that im curious aboout.
it is: int[,][] jaggedArr = new int[1, 2][];
I was wondering what I have done wrong about the piece of code ...
0
votes
1
answer
146
views
Word disappears in Console.Write();
My program shows the letter and then asks with what letter should you replace it:
static void Main(string[] args)
{
string textToEncode = File.ReadAllText(@"C:\Users\ASUS\Desktop\szyfrowanie2\...
0
votes
1
answer
209
views
how to print a single cell of an array inside a list of arrays in c#
I have a list of arrays:
List<int[]> a = new List<int[]>();
and i put in it a few arrays
int[] b = new int[3] {1, 2, 3};
int[] c = new int[4] {4, 5, 6, 7};
a.Add(b);
a.Add(c);
how can ...
2
votes
1
answer
3k
views
C# DataTable Show Single Row in Console
I have searched high and low for a method to show the entire row of a C# datatable, both by referencing the row number and by simply writing the row contents to a string variable and showing the ...