C
C#5mo ago
Array

✅ A bit of a beginner qustion, working with data types and variables. I can't seem to get it working

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Variables
{
internal class Program
{
static void Main(string[] args)
{
int x;
int y;

x = 7;
y = x + 3;

Console.WriteLine(y);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Variables
{
internal class Program
{
static void Main(string[] args)
{
int x;
int y;

x = 7;
y = x + 3;

Console.WriteLine(y);
Console.ReadLine();
}
}
}
I was expecting 10 to be outputted because of llgebra but unfortuanely I only see this black screen and the flicker. I have no red squaggles underneath anything. Anyone have ideas?? 😦
No description
33 Replies
Angius
Angius5mo ago
Weird, it should work just fine
Array
ArrayOP5mo ago
I can send a screenshot if needed Thanks for replying also
Angius
Angius5mo ago
You're using Visual Studio 2022? Running the code with the green arrow, F5?
canton7
canton75mo ago
Works fine here
Angius
Angius5mo ago
Any other files in the project?
Array
ArrayOP5mo ago
No, it’s just this
Angius
Angius5mo ago
Huh
Array
ArrayOP5mo ago
I used Console App (.NET Framework) Maybe that’s why?
SG97
SG975mo ago
just for giggles, f9 on the Console.WriteLine(y); (to insert a breakpoint) and f5 to start debugging
Angius
Angius5mo ago
You should not be using .NET Framework nowadays, but it should still run
Array
ArrayOP5mo ago
No description
Array
ArrayOP5mo ago
No description
Angius
Angius5mo ago
Were it not a .NET Framework project, I would've told you to try running it from the CLI
Array
ArrayOP5mo ago
Any relevance?
No description
Array
ArrayOP5mo ago
What’s that? Sorry
SG97
SG975mo ago
that is odd behavior
canton7
canton75mo ago
You've just stopped at a breakpoint
Array
ArrayOP5mo ago
One thing I notice is that “args” is white and underlined. Could be something as to why it’s broken?
canton7
canton75mo ago
Click on the red circle to remove it, and/or press "Continue" at the top / F5 to continue
SG97
SG975mo ago
was referring to the odd gray square
Array
ArrayOP5mo ago
gotcha
No description
canton7
canton75mo ago
Now you've selected part of the text of the console, which for annoying reasons pauses all execution Click somewhere in the console and press Enter
Array
ArrayOP5mo ago
GOT IT
Array
ArrayOP5mo ago
No description
Array
ArrayOP5mo ago
tHANK YOU so much Thanks guys
Angius
Angius5mo ago
You can run modern .NET projects with a dotnet run command from the console, without even needing Visual Studio It would let us tell if it's a VS problem, or code problem, by elmiminating VS from the equation
Array
ArrayOP5mo ago
How would I do that? Thanks for the suggestion!
Angius
Angius5mo ago
We,, you would start by making a non-Framework project $newproject
MODiX
MODiX5mo ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
Angius
Angius5mo ago
Or making it with the CLI, dotnet new console for example Shift-RMB in any folder would let you open a Powershell window in he location of the project Or you could open Powershell, CMD, or any other shell and navigate to that project with cd command Then dotnet run to run it
Array
ArrayOP5mo ago
Thanks a ton! Alright I’m gonna get sleep Good night guys
canton7
canton75mo ago
$close
MODiX
MODiX5mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server