C
C#8mo ago
Porfírio

❔ How do i fix that

The build failed. Fix the build errors and run again.
No description
18 Replies
Google
Google8mo ago
post code
mtreit
mtreit8mo ago
$code
MODiX
MODiX8mo 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
Google8mo ago
copy/paste errors instead of screenshots so it's easier for others to read.
mtreit
mtreit8mo 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
...
Porfírio
Porfírio8mo ago
im translating some variables so you guys can understand oh, i dont think it is necessary this is the code:
mtreit
mtreit8mo ago
Use $paste for long code snippets
MODiX
MODiX8mo 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!
Porfírio
Porfírio8mo ago
ok just a minute
mtreit
mtreit8mo 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?
Porfírio
Porfírio8mo ago
BlazeBin Basic - socwuffjgdjs
A tool for sharing your source code with the world!
Porfírio
Porfírio8mo ago
mtreit
mtreit8mo ago
So...this code has a lot of issues.
mtreit
mtreit8mo 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
mtreit8mo ago
But you do NOT want to write your code that way. I almost reget fixing it up.
Porfírio
Porfírio8mo ago
ok thanks
mtreit
mtreit8mo 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
Accord8mo 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.