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
2 answers

Basic Conditional C# Console App - Not writing anything to Console?

I was just wondering why the console doesn't write my string, but instead shows "Press any key to close". Would very much appreciate your help! using System; namespace oneToTen { public class Conditionals { static void Main() …
jwu
  • 13
  • 3
-1
votes
1 answer

Retrieving a value from database then apply a split function

I am applying a split function when receiving a column value from a database table. And I want to proceed this process while button_click event. but there is a problem the string is not showing in Console.Writeline Method. here is my code: protected…
Anurag Dixit
  • 27
  • 1
  • 1
  • 11
-1
votes
1 answer

Using String.Join in order to print a C# array - Performance

I want to print an array via Console.writeline. I'm lazy and want to do it in one line, avoiding iterating through all the array. Here is my code: var costumers = new Costumers[10]; // Array initialization... Console.WriteLine("Initial array:…
Maria
  • 53
  • 4
-1
votes
1 answer

How to prevent overwriting in a text file?

I have a trouble with the following code. It should prevent overwriting records in the text file. My code is like that: public static void WritingMethod() { StreamWriter Sw = new StreamWriter("fileone.txt", true); string output =…
Mina Hafzalla
  • 2,681
  • 9
  • 30
  • 44
-2
votes
1 answer

C# Console.WriteLine but text contains ""

I want to write something with Console.WriteLine, but the text contains "". Example: Console.WriteLine("example: "this is an example" example"); How to avoid this problem? I tried '' and other symbols, but it didn't work
simong
  • 3
  • 1
-2
votes
1 answer

convert to decimal in C#

When I use Console.ReadLine(), I input numbers without decimal(2000). Afterwards I need to show this number like decimal number(2000.00), using Console.WriteLine().How to do…
-2
votes
2 answers

I want to draw a pyramid using this 2 shapes { /\ } in c# but i got an error

Hi i wanna draw a pyramid that look like this /\ / \ / \ /______\ in Microsoft…
-2
votes
1 answer

using if to display an invalid text

hello I'm just a beginner in C# language I want to learn how to use "if" on this part of the code for example when I type a character or letter input in the console and pressed enter it should display a text "Invalid, please enter a valid value." or…
-2
votes
7 answers

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"
-2
votes
1 answer

Combining two Console.WriteLine(); public static voids

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, so it looks like a smooth paragraph when there is…
-2
votes
1 answer

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 rows don't start from the beginning of the line.(the column…
estrella
  • 33
  • 5
-2
votes
2 answers

Print values of ArrayList instead of classname

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) { x = this.x; y =…
DerDave
  • 11
  • 2
-2
votes
1 answer

How to print my name 100 times without any looping using C#?

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 advance!
Lina
  • 9
  • 1
-2
votes
2 answers

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.ReadKey()); } } this code works and has no errors but using…
Curulian
  • 111
  • 1
-2
votes
1 answer

Why is Console.WriteLine(i + "") faster than Console.WriteLine(i) in C#?

I tested the speed of i.ToString(), i + "", Console.WriteLine(i+"") and Console.WriteLine(i). (i was an int) The results were the following: i.ToString() (149 ms) was faster than i + "" (202 ms). But when I used Console.WriteLine Console.WriteLine(i…
user78403
  • 352
  • 2
  • 11