C
C#•2y ago
Down

Compiler error [Answered]

So im getting compiler error, i understand what it means but i dont know why i get it can you explain to me?
24 Replies
Down
Down•2y ago
im geting this error
Down
Down•2y ago
Down
Down•2y ago
there why cant i use the same name since its inside other case
Pobiega
Pobiega•2y ago
cases dont create scopes you can manually add a scope thou
Down
Down•2y ago
using { }?
Pobiega
Pobiega•2y ago
yes
Down
Down•2y ago
okay ill try thought they do thanks
Pobiega
Pobiega•2y ago
yw
Down
Down•2y ago
where would i need to add { }?
Pobiega
Pobiega•2y ago
below the case the first one
Down
Down•2y ago
yeah and wherei close
Pobiega
Pobiega•2y ago
so wrap all your "case code" in that
Down
Down•2y ago
tried and some are coloring in red
ero
ero•2y ago
wait for it pepelaughing
Pobiega
Pobiega•2y ago
var x = 123;
switch (x)
{
case 1:
{
var y = 343;
}
break;
case 2:
{
var y = "hello";
}
break;
}
var x = 123;
switch (x)
{
case 1:
{
var y = 343;
}
break;
case 2:
{
var y = "hello";
}
break;
}
the formatting gets wacky, but you get the point
ero
ero•2y ago
put the break in the scope too what how ugly is that
Pobiega
Pobiega•2y ago
oh lol
Down
Down•2y ago
okay all is working fine i forgot to add break at the end
Pobiega
Pobiega•2y ago
🙂
Down
Down•2y ago
the scopes work thanks do i close this or sum
Pobiega
Pobiega•2y ago
just type /close
ero
ero•2y ago
i was saying this because by default, VS adds indentations for case blocks
var x = 123;
switch (x)
{
case 1:
{
var y = 343;
break;
}
case 2:
{
var y = "hello";
break;
}
}
var x = 123;
switch (x)
{
case 1:
{
var y = 343;
break;
}
case 2:
{
var y = "hello";
break;
}
}
PISSED
Accord
Accord•2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server
More Posts
[EFCore] add many Parent entities with Child entities, How to connect them in single SaveChangesHello, im trying to sync data in my database with data in external source there is a example that i GroupBy cannot be translated usingHello I can't for example group data by month using one of class datetime attribute navigation propeMicrosoft.Xaml.Behaviors.Wpf MouseMove event passing event args to command is passing nullI have wpf application view. It is capturing MouseMove event, which is sending MouseEventArgs as theEnvironmental Variables in VS 2022 [Answered]```js { "profiles": { "Library.Dependency": { "commandName": "Project", "environmeNeed help getting cest timezonei currently have this code ```cs var timer = new PeriodicTimer(TimeSpan.FromSeconds(1)); wHei all, I am new to this Server and I realy need help on specific Problem [Answered]I am trying to move a .csv File from a Folder to another and it is actualy working but when I open tHow to send multiple data sources to a view in asp.net 6? [Answered]Hey, So im learning asp.net 6. I have a page where i show products by giving a list to the view, ButUncaught Exception C++ hostfxr HandlingHi I have a C++ dll that I am using to host some dotnet assembly and normally things work but when sEntity Data Model WizardI was watching this tutorial: https://www.youtube.com/watch?v=1oGxPoTGl0U&ab_channel=TekTuition AroWhen to use EF queries, LinQ, or MySQLClientAttached is one of the Entity Framework (EF) queries I'm referring to (I'm not sure if this is what