Click here to Skip to main content
15,890,882 members
Everything / Console

Console

console

Great Reads

by Marco-Hans Van Der Willik
This article continues with the development of the SOLID Poker project, and covers functionality to Compare and Validate Poker Hands.
by Robert S Sharp
I'm not sure that GC would matter very much in such a simple app.But, it's either a call to Dispose on your SmtpClient after you're done using it:smtp.Dispose();or use a using:using (SmtpClient smtp = new SmtpClient{ Host = "smtp.gmail.com", Port = 587, Credentials = new...
by Sunasara Imdadhusen
MS Test Result Viewer is a free open source library to convert MS Test result (.trx) file into HTML. It is also allowed you to perform MS Test on your test container project (.dll) file. This utility will work with simple command line arguments to generate test report in HTML format with excellent U
by Athari
CsConsoleFormat library for .NET - Formatting in Console using modern technologies

Latest Articles

by M@dHatter
Access private fields from Chained Extended classes
by Kenji Elzerman
A simple tutorial with some code of how to read text from an image with Azure Computer Vision
by SiretT
Console app to share internet connection with other network interface
by Shmuel Zang
Simple Java helper class to print colored text in console window.

All Articles

Sort by Title

Console 

9 Feb 2017 by JeezyWonder
i need to convert this console code to WInForms code. This code for HexDump format of recevieng data. I tried to convert "Console.WriteLine(Hex.Dump(example))" to "textBox4.Text (Hex.Dump(example))" Dont know is it correct or not, and still struggle with converting "console....
9 Feb 2017 by Dave Kreskowiak
Ummm... All you're doing is writing a string to the console. That's a function call to WriteLine and you pass in what you want to write.To do the same thing in a TextBox, that's setting the Text property of the TextBox. textBox4.Text = Hex.Dump(example);
1 May 2014 by Member 10362802
Dear sir or madam,I just learning to write c++ console app, and now encounter the problem of handling the windows-CLOSE event properly.Here's the context:----------------------------------------------------------------------------------------now the program is runing, if I click the...
1 May 2014 by Richard MacCutchan
I already explained the issue in your previous question at forrtl: error (200): program aborting due to window-CLOSE event[^]. You cannot capture Windows events/messages in a console program.
30 Oct 2013 by OriginalGriff
See here: http://bytes.com/topic/c-sharp/answers/273513-how-eject-cd-rom-c[^]
5 Nov 2016 by #realJSOP
This is not the place to go if you want someone to write code for you. I think I can safely say that nobody here works for free.This is a programmer's web site. I'm assuming that you think you're a programmer. If you can't come up with "any idea" on your own, maybe you should reevaluate your...
5 Nov 2016 by Patrice T
We do not do your HomeWork.HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will help your teacher spot...
5 Nov 2016 by johannesnestler
from the context you gave this is a homework about some special technique (LINQ) you learned in your lesson, your teacher want's to see you understood.I think you possibly made the studend/course thing before, so you may expected build up your solution on previouse lessons code.So even if...
6 Nov 2016 by Kats2512
this is not even a proper question. all I can see is:0000000000000000000000 00000000000000 0000000 0
30 Jan 2020 by Oleg Pruh
Hi, I work in Unity 2018.4.16f1 (64-bit). Today I had to build my project in Grudle, but there is a problem. Help me as soon as possible. Please do not write much, but to understand, you can write a solution step by step. 1 exception was raised by workers: See the Console for details. ...
30 Jan 2020 by Richard MacCutchan
java.lang.RuntimeException: Duplicate class com.unity3d.ads.BuildConfig found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:) Duplicate class com.unity3d.ads.IUnityAdsListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:) Duplicate class...
27 Feb 2020 by Member 14756217
Hello, I'm trying to remove a line from a text file, just something simple. I have a text file that has user information inside: UID: X Firstname: XXXXX Lastname: XXXXX Date Added: XXXXX So, what I'm trying to do is let the a "admin" input...
26 Feb 2020 by CPallini
You know it works this way Open the original file for reading and read it line by line. Copy only the wanted lines to another file (the 'output' file, that is open for writing) At the end of the process, delete the original file and rename...
26 Feb 2020 by OriginalGriff
Test files don't contain "lines". Yes, yes, I know - you can read and write lines, so obviously they do contain them. But in practice, they don't - they contain a stream of characters some of which are interpreted as a "newline" by software...
29 Nov 2017 by Greek Varak
Madhan has been a given a problem by his brother Jayi .The problem is related to strings. Now he gives Madhan a long String S which consists of lowercase English Alphabets and wants him to tell the minimum size of substring such that all the substrings of that size in S have at least K...
25 Nov 2017 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
29 Nov 2017 by Member 13549143
This may help public static int Consonant(String input1,int input2) { int consonant = 0; int total =-1; int count =0; String str=""; int tot_substring =0; for (count=1;count
17 Feb 2014 by KUMAR619
How to insert new elements into an existing array without overwriting the existing values.Console.Write("Enter the size of the array: "); string inputSize = Console.ReadLine(); int stringSize; int.TryParse(inputSize, out stringSize); ...
17 Feb 2014 by Sergey Alexandrovich Kryukov
I already answered: How to insert elements into an existing string array[^].With your behavior, you should rather leave this site. Helping you is totally useless.—SA
4 May 2020 by honey the codewitch
Start out with the basics for command line argument processing and exception handling for your console based utilities
6 Jan 2020 by honey the codewitch
Easily add progress reporting to your console apps
28 Jul 2016 by GVO2016
I am working on a project and have some code that works correctly as a console application. Now i need to convert it to a Windows Form Application and have been having trouble. I've been working on it for a fews days, and as someone who is not an experienced programmer I would appreciate any...
28 Jul 2016 by CPallini
Google is your friend: VB NET GUI development tutorial[^].
28 Jul 2016 by Ralf Meier
To give you an approach :- you create a Form- you place 3 Textboxes (one for each of you variables A,B,C) on this Form- you place a Label (for displaying the result) on the Form- you place a Button (for the calculation) on the Form- you create a Script like your Sub Main which should...
22 Mar 2014 by mohammadali1375
Hi.I have this batch fileSET jlinklocation = D:\Program Files\SEGGER\JLinkARM_V482\cd /d %jlinklocation %(echo Device AT91SAM7S64echo loadbin C:\binfile.bin 0X100000)|jlink.exeexitMy problem is taht the AT91SAM7S64 have an space after it. and jlink program want use this...
22 Mar 2014 by Sergey Alexandrovich Kryukov
First of all, you cannot use "%jlinklocation %", it should be "%jlinklocation%", otherwise reference to the set symbol won' work. As to the blank space in "AT91SAM7S64 " and related problem is not manifested in your code sample anyhow.echo Device AT91SAM7S64simply outputs string in the...
17 Jan 2012 by Lodewijk Pool
A quick and easy way to direct Java System.out to File and to Console.
2 Feb 2012 by Member 3896609
try{ FileOutputStream fout= new FileOutputStream("stdout.log"); FileOutputStream ferr= new FileOutputStream("stderr.log"); TeeOutputStream multiOut= new TeeOutputStream(System.out, fout); TeeOutputStream multiErr= new TeeOutputStream(System.err, ferr); ...
6 Jul 2016 by Kishor-KW
I want to access private constructor in other class. Can it is possible through chaining of constructor. I tried following code for it but it is not allowed. in following code i declared variable k1=1 in class then change it in private constructor k1=2. when i create a object of other...
6 Jul 2016 by Dave Kreskowiak
You can't. Private means that it is only accessible inside the class it's declared in.You've also got a couple of variables reversed in your constructor that takes an int as a parameter. It should be: public Program(int k) { k1 = k; }
6 Jul 2016 by User 59241
You should first address the design of your classes if you find yourself in this situation.c# - Why do we need a private constructor? - Stack Overflow[^]Here is a hack using reflection that you may wish to try:Accessing a Private Constructor from Outside the Class in C# - Stack Overflow[^]
24 Apr 2015 by Geo Jackson
HiI have to add a configuration tag in app.config, how can i access the tag values in C#.I have already googled and got some solutions. I tried that and got the below error"Only one element allowed per config file and if present must be the first child of the root ...
24 Apr 2015 by Varun Sareen
Dear Friend,Your error says it all. Correct your code like this:- for reference:-Visit (^)configSections must be the first child of the root element:This link will help you out:- Access Custom Tag in...
9 Dec 2016 by Shesh Lamichhane
Step by step to add the transformation files of app.config in your .NET Windows service
22 Dec 2012 by rlilley
I am currently working on a project in Visual Studio 2012 that needs to send an existing file from one folder to my Dropbox public folder in zipped format, get the Dropbox public link and email the link to a list of users. I am having a problem getting the Dropbox Public LinkI have written a...
22 Dec 2012 by Zoltán Zörgő
As I see, you tried to wrap an application around some existing command line tools and IE. I suggest you look for and use dedicated .net libraries for those tasks.Like these ones: 1) ZIP: http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]2) DropBox:...
22 Dec 2012 by BillWoodruff
I can see, by your response to my comment on your question, that you have already figured out the essential aspect of accessing files in your own DropBox, on your own computer.Yes, DropBox files in the Public folder, on your machine, use a hard-coded six-digit ID number; however, shared...
9 Jun 2015 by agent_kruger
I have a project that is made on windows form and returns output (.exe) but i want it to return output file in (.dll). The reason why i want it in dll file is because this software has some additional features which every user shouldn't posses. Note:- i cannot change projects output type...
9 Jun 2015 by Sergey Alexandrovich Kryukov
Application type should be "class library".Yes, I mean it. And then, in a library, you don't need entry point (static Main method). But if you leave it there, the library will still work: you can reference it in other application and then use the forms from your DLL. Technically, the only...
16 May 2013 by osama.javed
Hi, How can I Create shortcut of an application in Start Menu using C#.I shall be thankful for your HelpRegards,Usama Javed
7 Feb 2014 by Member 10362802
Dear all,I am trying to write a C++ win32 console application, but have trouble in: 1.interact with user's input and dispatch it to others threads. 2.mutithread synchronization. ....Can somebody send me a demo project or just print a link related to this topic?I...
7 Feb 2014 by CHill60
Hopefully these will get you started ... the last one is not on CodeProjectUsing WIN32 Message Queue in C++ / WIN32 Multithreaded Applications[^]Simple Multithreaded Application in pure C, Win32 and MFC[^]The Practical Guide to Multithreading - Part 1[^]Multithreading...
13 Feb 2015 by Member 11166005
public string FindFace() { string ex = Path.GetExtension(lbFileName.Text); var uniqueName = Guid.NewGuid(); var myUniqueFileName = string.Format(@"{0}{1}", uniqueName, ex); Console.WriteLine("Answer...
13 Feb 2015 by phil.o
The best practice when it comes to build file system paths is to use a dedicated method:string result = Path.Combine(path, myUniqueFileName);This will take care that you get a valid path specification.More here: MSDN: Path Class[^]
31 May 2012 by madhuri@mumbai
Hello All,I want to convert the alphanumeric value to integer,is it possible? if yes then please share with me.
31 May 2012 by Richard MacCutchan
See here[^]. Incidentally, this has nothing to do with boxing & unboxing.
4 Sep 2018 by Numan Doğruay
Hello guys. I'm trying Asset Bundle Build via command line and i can do. With this code: Object[] selectedAssets = Resources.LoadAll("Prefabs"); Object[] videos = Resources.LoadAll("Prefabs"); Debug.Log(bundlePath); Object obje = new Object(); ...
19 Oct 2017 by E.Açıkgöz
Write a program that reads there integers from the user(keyboard) namely, n, a and b. Your program sohuld print all positive numbers satisfying the following condition: *The number smaller than n and the ratio of the number and sum of its positive divisors is equal to a/b. You should print the...
19 Oct 2017 by Richard MacCutchan
The following code makes no sense. The first iteration of your loop will terminate your program. for(i = 1; i
19 Oct 2017 by KarstenK
You should write for every needed output a function which deliver it and than do the output. You can define an array like this, but you also need to free the memory: int *arr = 0;// define pointer int count = fillArrayFunc( arr, a, b, n ); for( int i = 0; i
15 Jun 2013 by sizusuzu
Can I develop an application that is not Windows form, i.e. that is Console application using EMGU CV? I want to do the image processing on the desktop using C# and Emgu CV and send the result to an Android via Http. Can I do it as a console application using Emgu CV?
15 Jun 2013 by Zoltán Zörgő
Yes, of course. You have experienced something else?
27 Mar 2018 by Johannes Grunedal
Hi! I have a C# application which communicates with a console window (via SetForegroundWindow and sendKeys). This works great and I use that for sending commands to the console window (I also start another DOS program inside the command prompt).The PROBLEM is that I would like to read back...
17 Apr 2015 by Andy Lanng
There are two parts to a process run in a cmd terminal: the process and the terminal itself.When you run a command in the terminal, that command will output to a buffer. if that buffer gets full then the process waits for the buffer to be read so it can continue.The terminal reads from...
17 Apr 2015 by Andy Lanng
I want 5 start ^_^This is a whole class. It doesn't use any assemblies outside of the standard libraries. it can be made even nicer with RX for example, which allows you to turn events into IEnumberables in a much better way that I have done here.If your looking for that, search for...
27 Mar 2018 by Andy Lanng
Updated to 2017: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading; namespace ProcessWithOutput { public class ProcessWrapper : Process, IDisposable { public enum PipeType { StdOut, StdErr } public class...
13 Mar 2013 by mayanktripathi01
I'm writing a C# console application that scrapes data from web pages. This application will go to about 8000 web pages and wait till web page is completly rendered with data.I have it working right now with no async methods and no multithreading.However, I need it to be faster. It only...
13 Mar 2013 by Jegan Thiyagesan
Hiyou asked the same question last time.Need to implement Threading in C# console application[^]What didn't work?Jegan
18 Dec 2018 by TheBigBearNow
Hello all I have a loop in a console application. I am using a while loop and grabbing the users input. I am checking the input and if the input isn’t valid I would like to go to the beginning so they can try again. Currently once they are wrong I am stuck at the end it doesn’t matter if they...
18 Dec 2018 by Ehsan Sajjad
Your following condition seems to be culprit. You are using inserted variable while you are taking input and putting it in userChar. Either use inserted at both places or change your while condition. Try the following: if(char.TryParse(input, out char userChar)) { answers[i] = userChar;...
5 Dec 2021 by Member 13998042
I am trying to create a console application . i am using restsharp package to call a restapi . i am getting error in "acceptallcert". and the error is "an object reference is required for the non-statis field,method or property...
5 Dec 2021 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
3 Sep 2012 by lichoniespi
im having huge problem with application i made for windows server 2008 R2.The application works on .NET framework 3.5, and as far as i know windows server 2008 R2 contains such a framework.Application itself is pretty massive, it is a server program for registering employees work time,...
10 Mar 2013 by ali_heidari_
find main method wich is first method to start debug !write this line : System.Windows.Forms.Application.Run(new Form1()); // i consider Form1 is your windows form classthis line will make your windows form and will show it !do not forget to add System.Windows.Forms to your project...
10 Mar 2013 by F. Aro
In your Program.cs You Must Run the GUI on another Thread :Just add For Exemple:Console.Write("Running the GUI...\nPress Enter To Abort"); new System.Threading.Thread(()=>{System.Windows.Forms.Application.Run(new ...
10 Mar 2013 by wingzero007
By keeping the same project, you can change the output type:1. Go to the properties of your project (right click on the project in VS).2. In the context menu, choose properties.3. In the window that appears, Select the Application tab (Should be the first one by default).4. Change the...
29 May 2023 by Flo_89
Hello :)For testing purposes I created a C# ConsoleLine application. Now I want to do a GUI and so I choose Project --> Add component and added a "Windows Forms" element. But although there is no Console.WriteLine or something left he always opens the Console and he does not show my Windows...
18 Dec 2011 by Joel Whatley-
int position1H = 3; int position1V = 3; int position2H = 75; int position2V = 3; while (true) { Console.SetCursorPosition(position1H, position1V); Console.BackgroundColor =...
18 Dec 2011 by Sergey Alexandrovich Kryukov
You should use System.Console.ReadKey(true), but in a separate thread, that's it. This call will block the calling thread until some key is hit, and no feedback will be shown, thanks to this method's parameters. Another thread will show output without pause. Pretty simple.I'm not sure...
20 Dec 2011 by Joel Whatley-
This: string player1name = Console.ReadLine(); string player2name = Console.ReadLine(); Console.Title = ???How do I put the player names in the title?I tried: Console.Title = "{0} vs. {1}", player1name, player2name; etc. etc. but...
20 Dec 2011 by MaulikDusara
HI,Please check this.http://www.dotnetperls.com/console-title[^]
29 May 2014 by Member 10847268
Hello guys! I have this piece of code that I am willing to be converted to a windows forms application in c#!using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ComponentModel;using System.Data;using System.IO;namespace Bruteforce{ ...
29 May 2014 by OriginalGriff
The algorithm remains the same - unlikely to help you brute force attack a password in a reasonable time period, thankfully - all you need is to output them differently: instead of Console.Writeline, you need to pass them back to the "calling process" in some way: either by passing a ListBox...
29 May 2014 by BobJanova
This is a silly application, but presumably you know that. That algorithm's not useful for anything.Console and windowed desktop applications have somewhat different use paradigms, so it isn't so much a case of 'converting' as working out how your core algorithm should be presented in the...
18 Jan 2017 by MaikelO1
I use te POSTMAN application to upload a file to an API, now I want to actually do a POST commando in c#, how can I do this in the most efficient way?url "192.168.0.1/api/files"Header key= Authorization, value = "123456"Formdatakey= files, value = key= Info, value =...
18 Jan 2017 by Richard Deeming
Use the MultipartFormDataContent class[^]:using (var form = new MultipartFormDataContent())using (var stream = File.OpenRead(@"Path\To\Your\File.ext"))using (var streamContent = new StreamContent(stream)){ form.Add(streamContent, "files"); form.Add(new...
26 Jan 2016 by Member 12289776
Hi,My requirement is to have a console app which listens all the events of iis using etw listner concept in c#.For example, if we open IIS we should be able to cature the ProcessStart event and similary when we close ProcessClose event should be able to capture.I am able t capture close...
4 May 2020 by Member 11955245
Need some guidance here - Requirement- I have 1000 SQL servers and I have a scheduled task running on all of those which updates a table with just an integer, let's call it X (its a sum of some numbers). Now the ask is to create some sort of...
4 May 2020 by RickZeeland
Maybe you can use ApexSQL Propagate instead of writing a C# application: Multi-database SQL script execution | ApexSQL[^] Or take a look at this CodeProject article which uses SignalR: SQL Server Notifications on Record Change with SignalR and...
4 May 2020 by Dave Kreskowiak
Well, if you can't use 3rd party solutions, you're going to have to write a service that runs on all of the SQL Servers. This service would get the data it needs from the server it's running on and send it to a central SQL database. Your website,...
27 Mar 2013 by metastruct
When WebClient, HttpRequest, and all else fail, BITSadmin solves your download woes
10 Nov 2020 by Yisrael Lax
.NET Library for automatically validating and casting console input parameters
30 Jul 2020 by DiponRoy
Making schedule jobs exe using Quartz scheduler
5 Feb 2014 by frostcox
Hey guys, I'm just wondering if you could help me and possibly give me some suggestions on how to achieve this. Ok, We have a file transfer solution which moves files from A to B and then to C. Files take a long time to transfer from A to B as there is over 300,000 files on the remote server so...
5 Feb 2014 by pdoxtader
It seems to me that what you really need is a faster way to get the list of files on the file system, rather then keeping 30 files or so in memory.In fact, a better solution given what you've written here is to keep the PATHS of those 30 critical files in memory, or in a log file - and have...
27 Nov 2013 by Temur Mukbaniani
I want to calculate the sum of ListNodes, but it says that "'s' Specified cast is not valid."using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ class...
27 Nov 2013 by OriginalGriff
You can't cast a ListNode to an integer - that's just silly! foreach (object s in listOfNodes) sum += (int)s;s is a ListNode - because that is what your GetEnumerator method returns: public IEnumerator GetEnumerator() { ...
27 Nov 2013 by Matt T Heffron
OriginalGriff suggested changing what the enumerator returned.I'd argue against that because it is not the expected semantics of GetEnumerator().I'd use object less and correct types more:public class List : IEnumerable ...andpublic IEnumerator GetEnumerator()...
9 Jul 2013 by Makarand Borawake
How to calculate time remaining to copy data from one drive to another and display it on console??
9 Jul 2013 by Sergey Alexandrovich Kryukov
It can never be precise, unless you show not time but bytes to copy (I would recommend that). If you have the same volume in smaller files, the process goes slower, and it depends on some other factors.—SA
27 Dec 2014 by KP Singh Chundawat
Hello folks,I have one windows service which runs on server. I have one html file(which is also deploy on IIS Like www.xyz.com/index.html) which has one javascript library which have number of function with arguments. I want to call specific function from this JS with argument using...
27 Dec 2014 by Zoltán Zörgő
The answer to your question: no, you can't. There are many reasons for that.Let me suppose that there is an event on server side, comming from the windows service, and you want all or some active clients to react to that (for example by sending some data not yet sent to the server side). The...
17 Mar 2014 by Morore_Charles_007
HiI have a vake question i need a code example on how to call/ invoke a webservice in a console application and display for the user
17 Mar 2014 by Krunal Rohit
Your first C# Web Service[^]http://support.microsoft.com/kb/308359[^]http://www.csharptutorial.in/2012/01/cnet-how-to-create-web-service-in-cnet.html[^]The first link is a hell of an example, awesome one... :) :D-KR
18 Dec 2011 by Mostafa8
Hi,allI'm developing a proxy server application which cache the most visited & browsed webPage.I want to capture requests sent from the client computer, then record the urls in a notepad file, then compare between them for the highest visited site & Cache it,If u have a sample for...
18 Dec 2011 by Sergey Alexandrovich Kryukov
How can it work if you don't try to accept anything? This is not how TcpListener works. Read properly: http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx[^].Also, you are trying to heavily abuse threading. You are trying to create more and more threads in a loop! (An...
8 Mar 2014 by Sergey Alexandrovich Kryukov
Better think of something better. In principle, something similar is possible, but what's the use? the quality… and realism… hard to think of something as frustrating as that. Direct addressing of output point is quite possible, and even timing, but the main problem is: 2D modeling...
10 Dec 2015 by morris “mason” bonham
This code should encrypt and decrypt text with RSA cipher. If I have spaces in text for encryption, then it doesn't encrypt words after space. Also it doesn't show possible values of e & d.#include...
10 Dec 2015 by OriginalGriff
Do you have any idea how much work explaining code line by line is?Every single line needs a paragraph of explanation! For example: int next = r.Next();Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call...
10 Dec 2015 by Sergey Alexandrovich Kryukov
Please see my comment to your comment to Solution 1.morris “mason” bonham asked:Maybe someone have done anything familiar and can share it…Look, for example, at this implementation: https://code.google.com/p/rsa[^].But don't expect explanation of the code. OriginalGriff and I...