[Solved] C# console application returns: “not all code paths return a value” [closed]

You need to return a string value from DoWork function. this code only execute Working function, but didn’t return string value from DoWork function. public string DoWork() { Working(); } so you might return a value from DoWork function because DoWork method signature must return a string value. public class SomeType { public string DoWork() … Read more

[Solved] How can one verify whether consecutive letters have been entered from the qwerty keyboard in a delphi console application?

Try something like this: function HasThreeConsecutiveLetters(const Str: string): Boolean; const QwertyLetters: array[0..2] of string = ( ‘QWERTYUIOP’, ‘ASDFGHJKL’, ‘ZXCVBNM’ ); var I, J, K: Integer; S: String; begin Result := False; S := AnsiUpperCase(Str); for I := 1 to Length(S) do begin for J := Low(QwertyLetters) to High(QwertyLetters) do begin K := Pos(S[I], QwertyLetters[J]); if … Read more

[Solved] Cannot Implicitly Convert int to int[] [closed]

This is because you are trying to assign arrays instead of assigning their members: idArray = Int32.Parse(words[0]); should be idArray[i] = Int32.Parse(words[0]); and so on. Better yet, create EmployeeData class that has individual fields for id, name, dept, and so on, and use it in place of parallel arrays: class EmployeeData { public int Id … Read more

[Solved] Find how many cores are being used by a c# application

It’s difficult to get a precise answer without using specific performance monitoring tools, and it does vary moment to moment. I’d suggest using Perfmon while running your application as a starting point for your analysis. If you’re using certain versions of Visual Studio, you can also try Analyze | Performance Profiler. If you want a … Read more

[Solved] How to make small changes for console output without repeating all unchanged values

You should not reprint all the map for each cycle. The better way is to use Console.SetCursorPosition method and rewrite just modified symbols: foreach(var changedSymbol in changes) { Console.SetCursorPosition(changedSymbol.Row, changedSymbol.Column) Console.Write(changedSymbol.Value); } 1 solved How to make small changes for console output without repeating all unchanged values

[Solved] How to declare and initialize multiple variables (with different names) within a for loop without using arrays?

You cannot create dynamically named variables in C# (and I am with those who are wondering why you want to do that). If you don’t want to use an array, consider a Dictionary — it would perform better than an array in some circumstances. Dictionary<string, int> values = new Dictionary<string, int>(); for (int i = … Read more

[Solved] “argument of type ”int(*)()“ is incompatible with parameter of type int” error?

int bla(int, int, int, int); bla function expects int arguments but double n = bla(sum, budget, bet, new_budget); you are passing sum as a parameter which is a function. As your sum function returns an int, you can pass it as sum() double n = bla(sum(), budget, bet, new_budget); Side Note: Inside sum function you … Read more

[Solved] Shooting. Collision of the shot with a collection of List

Without claiming to rework your design, I added collection of dead invaders(ArmyOfInvaders.deadInvader) to stored those ones, who already shot, and changed InvaderGotShot and DrawItem methods. I got rid of Invader.invader collection and introduced local variable in Invader.InitializeInvader instead of it to prevent misassigning. Please take a look: class Program { static void Main() { Settings.ScreenSettings(); … Read more

[Solved] Opening and writing to form from console aplication [closed]

If you want to open the form with a console application, you can refer to the following steps: First add this code in .csproj file of the console application: <Project Sdk=”Microsoft.NET.Sdk”> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> <UseWindowsForms>true</UseWindowsForms> </PropertyGroup> </Project> Second add project reference of GUI VISUIALZATION: Finally you can refer to the following code in console application: … Read more