C
C#13mo ago
Zyxtan

❔ How do i fix that

The build failed. Fix the build errors and run again.
No description
18 Replies
Google
Google13mo ago
post code
mtreit
mtreit13mo ago
$code
MODiX
MODiX13mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Google
Google13mo ago
copy/paste errors instead of screenshots so it's easier for others to read.
mtreit
mtreit13mo ago
"Cannot declare instance member in a static class" should be straight-forward. Show your code. Do you have a class defined with the static modifier? Something like:
static class Something
...
static class Something
...
Zyxtan
ZyxtanOP13mo ago
im translating some variables so you guys can understand oh, i dont think it is necessary this is the code:
mtreit
mtreit13mo ago
Use $paste for long code snippets
MODiX
MODiX13mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Zyxtan
ZyxtanOP13mo ago
ok just a minute
mtreit
mtreit13mo ago
That code doesn't remotely come close to compiling.
public static class processamentos
{

public void processarEntradas(string letra)
{
public static class processamentos
{

public void processarEntradas(string letra)
{
So here's one clear issue. Why do you have this defined as a 'static' class when you have non-static methods?
Zyxtan
ZyxtanOP13mo ago
BlazeBin Basic - socwuffjgdjs
A tool for sharing your source code with the world!
Zyxtan
ZyxtanOP13mo ago
mtreit
mtreit13mo ago
So...this code has a lot of issues.
mtreit
mtreit13mo ago
Here is a version that compiles: https://paste.mod.gg/fccxtzieyzez/0
BlazeBin - fccxtzieyzez
A tool for sharing your source code with the world!
mtreit
mtreit13mo ago
But you do NOT want to write your code that way. I almost reget fixing it up.
Zyxtan
ZyxtanOP13mo ago
ok thanks
mtreit
mtreit13mo ago
In C# fields and properties are associated with a particular class (either at the type level or at the instance level) which means you can't just assume fields in one class are available in some other class without actually telling the code which class you are talking about.
using System;

public static class A
{
public static int Something = 123;
}

public static class B
{
public static void DoSomething()
{
Console.WriteLine(Something); // Error: 'Something' is not a thing this class knows anything about.
Console.WriteLine(A.Something); // This is OK because you told it where to find the Something field, namely that it is part of the A class.
}
}
using System;

public static class A
{
public static int Something = 123;
}

public static class B
{
public static void DoSomething()
{
Console.WriteLine(Something); // Error: 'Something' is not a thing this class knows anything about.
Console.WriteLine(A.Something); // This is OK because you told it where to find the Something field, namely that it is part of the A class.
}
}
Your code is doing something like the Error case illustrated here. Also don't use public static fields in general. Use properties instead. Also you probably don't want to blindly make everything static.
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server