✅ Foreach Loop Printing Multiple Chars from a String Simultaneously
Prints
Surely
H
and e
shouldn't be printed on the same line? What am I misunderstanding here?31 Replies
Angius
REPL Result: Success
Console Output
Compile: 614.117ms | Execution: 47.159ms | React with ❌ to remove this embed.
It works fine
Weird. Online C# compilers are evidently not the way to go.
They do have their quirks
Although the reputable ones like Sharplab should work just fine
Do I need to set this thread to
resolved
or something?You can use
/close
if you wantI'll check that out. Thanks.
Ideally, though, just run the code locally
Ah perfect. Thanks for the super speed reply 🙂
Much better experience
Yeah I'm struggling to make it work in VS Code, only works in VS 2022 right now.
Could you help me figure it out?
Sure
$vscode
Follow the instructions here on getting started with DevKit for C# in VSCode: https://code.visualstudio.com/docs/csharp/get-started
Get started with C# and .NET in Visual Studio Code
Getting Started with C# and .NET Development in Visual Studio Code
I don't know how to make a program run, it just says that I haven't created a project, but I've no clue how to do that.
Ah, well, C# is project-based
Not file-based like Python or PHP
Interesting. So how can I create one in VS Code?
You can't run just a loose
myprogram.cs
file
dotnet new
command
dotnet new console
for example, will create a CLI projectIn the VS Code console?
Yep
Awesome gimme two secs I'll go try that
It will create a
Program.cs
and MyCoolProject.csproj
files, which is the minimum needed for a C# project to workI imagine this will be an issue?
Huh
I guess install Powershell...?
It's a school computer and powershell is blocked. Probably that?
It works for Unity soo
Ah, could be
Does Unity not use .NET?
It uses its own weird fork of Mono, last I checked
They are working on migrating to .NET 6, I believe
Is that the MonoBehavior identifier next to all the scripts' classes?
But they're taking their time, .NET 8 came out today lol
No,
MonoBehavior
would be the base class
:
is inheritanceHaha yeah I was about to say, why not at least .NET 7
Ahhhh so that's how inheritance works.
class MyThing : MonoBehavior
means MyScript
inherits MonoBehavior