C
C#

help

Compiler error [Answered]

DDown10/10/2022
So im getting compiler error, i understand what it means but i dont know why i get it can you explain to me?
DDown10/10/2022
im geting this error
DDown10/10/2022
DDown10/10/2022
there why cant i use the same name since its inside other case
PPobiega10/10/2022
cases dont create scopes you can manually add a scope thou
DDown10/10/2022
using { }?
PPobiega10/10/2022
yes
DDown10/10/2022
okay ill try thought they do thanks
PPobiega10/10/2022
yw
DDown10/10/2022
where would i need to add { }?
PPobiega10/10/2022
below the case the first one
DDown10/10/2022
yeah and wherei close
PPobiega10/10/2022
so wrap all your "case code" in that
DDown10/10/2022
tried and some are coloring in red
Eero10/10/2022
wait for it pepelaughing
PPobiega10/10/2022
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
Eero10/10/2022
put the break in the scope too what how ugly is that
PPobiega10/10/2022
oh lol
DDown10/10/2022
okay all is working fine i forgot to add break at the end
PPobiega10/10/2022
🙂
DDown10/10/2022
the scopes work thanks do i close this or sum
PPobiega10/10/2022
just type /close
Eero10/10/2022
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
AAccord10/10/2022
✅ This post has been marked as answered!

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
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 Process Checker [Answered]I'm creating an ""antivirus"" and I'm using a thread to check when a new process is started (but theArgumentNullException when argument is not nullI have this code: ```cs public class Config { [JsonProperty("token")] public string Token = "TOKWPF reusing the same template across multiple columnsThe following question https://social.msdn.microsoft.com/Forums/silverlight/en-US/f84e0efd-b1f2-4ab6Cascading DropDownI'm using MVC (.NET5) with EF and had this code to select a species on a View (to Create/Edit): ```cAssembly service findingHi, I am trying to find out if it's possible to get IServiceProvider, Microsoft IConfiguration or sohow do i submit a progra min vs to google classroomim trying to submit a project that's due to today but when i do submit it all i get is this and not WPF custom property not recognized by the compilerI have defined a custom property like below, it's in the namespace `CarApp`. It is supposed to repreEntity Framework DbContextOptionsBuilder.UseSqlServer() missing definitionI just installed the newest version of Entity Framework (6.0.9) and am inside my program.cs trying tDoes API manual nuget downloads come with the package dependencies?-WPF passing binding to a template from DataGridTemplateColumnSay, I have a template like this in resources, which I want to reuse for multiple columns, and whichBest way to implement a regex based lexer [Answered]In a regex lexer, you can loop over every pattern and do something like this: ```cs if (match.Succes