console-application

How to increase the size of the console window in C#?

廉价感情. 提交于 2019-12-01 18:58:34
I'm creating a prototype for a piece of functionality that I will be implementing in an application, specifically I am displaying data from a collection to the console window but unfortunately some of the lines span wider than the default width of the console window. I've done a bit of digging and found that the only way to increase the width of the window is to dig into the Kernel32.dll and do it manually. As elegant as pInvoke is, does a "shorter" way exist to increase the width e.g. (Console.Width = 300) or is using the Kernel32.dll the only way. Thanks! No programming is required. Create a

How do I make an console application run until the user enters “Q”, “q”, “Quit” or “quit” to terminate it?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 18:55:54
How do I make an console application run until the user enters "Q", "q", "Quit" or "quit" to terminate it? This is my current code: public class Class1 { [STAThread] static void Main(string[] args) { string userName; int i = 0, totalCal = 0, cal = 1; Console.WriteLine("Welcome to the magical calorie counter!"); Console.WriteLine(); Console.Write("Enter in your name -> "); userName = Console.ReadLine(); for (i = 0; i <= 10; i++) { Console.WriteLine("Hello {0}.....Let's add some calories!!", userName); }// end for loop Console.WriteLine(); while (cal != 0) { Console.Write("Enter some Calories:

Monodevelop on Ubuntu Console.ReadLine doesn't work

こ雲淡風輕ζ 提交于 2019-12-01 18:55:09
I'm trying to develop on Mono platform on Ubuntu. But I got trouble on my first application :) Here is the code: using System; using System.Threading; namespace threadings { class MainClass { public static void Main (string[] args) { Console.WriteLine ("The start"); string x=Console.ReadLine(); Console.WriteLine(x); Console.WriteLine ("the end"); } } } And here is the result: The start the end And no any string between them, and no reading from console happens, and I can't input anything. What is the problem? Maybe I do something wrong? My environment: Ubuntu: Linux nozim-desktop 2.6.32-32

How to increase the size of the console window in C#?

我是研究僧i 提交于 2019-12-01 17:38:32
问题 I'm creating a prototype for a piece of functionality that I will be implementing in an application, specifically I am displaying data from a collection to the console window but unfortunately some of the lines span wider than the default width of the console window. I've done a bit of digging and found that the only way to increase the width of the window is to dig into the Kernel32.dll and do it manually. As elegant as pInvoke is, does a "shorter" way exist to increase the width e.g.

How to add a web service reference in Visual Studio 2015 to a console app

徘徊边缘 提交于 2019-12-01 17:27:46
问题 Is there a way to easily add a web service reference to a Visual Studio 2015 console application? 回答1: Right click References -> Add Service Reference. (i.e. don't right-click the Project name.) 回答2: If you don't have References -> Add Service Reference, you probably use VS2015 and new Console Applicaiton template, to add WCF service you need to: Right click on References -> Add Connected Service Click 'Find more services...' at the bottom of window. Search for 'Visual Studio WCF Connected

Message pump in a console application

最后都变了- 提交于 2019-12-01 16:54:05
问题 I have a fairly simple console application written in .NET. Sometimes the application is run in batch mode without an operator, other times it is run "out of pocket". If it's running in batch mode, there is a defined default option which allows the program to run automatically. If there is an operator present, there are other options which allow the user to select from a list of functions. For reasons I don't want to go into, command-line parameters are not preferred. Instead, I've created a

Console Application - WriteLine above current working line

[亡魂溺海] 提交于 2019-12-01 16:01:45
问题 I have seen a few other posts very similar to this one, but the answers they give are not correctly answering the question. Sorry if there is something hidden away that I couldnt find... I want to use Console.WriteLine() to print something above my current Console.ReadLine(), for example, my app prints "Hello world" and starts a thread that (in 5 seconds) will print "I just waited 5 seconds" above the line where I need to input something, like this: Hello world Please input something: _ Then

Run a program as user identity but with elevated privileges

随声附和 提交于 2019-12-01 15:54:54
Scenario: An administrator will install the application. The application has some kernel level operations so, it has to run with privileged mode. But the user does not have administrator credentials to run the application in elevated mode. So, what are the best possibility to solve the above scenario. Solution one (tried): While installing the application through administrator, we would create an admin where we know his user name and password. So, when the user tries to perform any operation, we will run the application as elevated mode using the functions processstartinfo() and process.start(

How to print 2D array to console in C#

狂风中的少年 提交于 2019-12-01 14:49:55
I dont't have any code for this, but I do want to know how I could do this. I use visual studio 2010 C# if that matters. Thanks Jason public static void Print2DArray<T>(T[,] matrix) { for (int i = 0; i < matrix.GetLength(0); i++) { for (int j = 0; j < matrix.GetLength(1); j++) { Console.Write(matrix[i,j] + "\t"); } Console.WriteLine(); } } you can print it all on one line int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; Console.WriteLine(String.Join(" ", array2D.Cast<int>())); output 1 2 3 4 5 6 7 8 alessandro You should read MSDN:Using foreach with Arrays int[,]

Run a program as user identity but with elevated privileges

百般思念 提交于 2019-12-01 14:41:04
问题 Scenario: An administrator will install the application. The application has some kernel level operations so, it has to run with privileged mode. But the user does not have administrator credentials to run the application in elevated mode. So, what are the best possibility to solve the above scenario. Solution one (tried): While installing the application through administrator, we would create an admin where we know his user name and password. So, when the user tries to perform any operation,