18 Replies
post code
$code
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/copy/paste errors instead of screenshots so it's easier for others to read.
"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:
im translating some variables so you guys can understand
oh, i dont think it is necessary
this is the code:
Use $paste for long code snippets
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!
ok
just a minute
That code doesn't remotely come close to compiling.
So here's one clear issue. Why do you have this defined as a 'static' class when you have non-static methods?
https://paste.mod.gg/basic/viewer/socwuffjgdjs/0 like this ?
BlazeBin Basic - socwuffjgdjs
A tool for sharing your source code with the world!
BlazeBin Basic - hdqtxrdkfjhn
A tool for sharing your source code with the world!
So...this code has a lot of issues.
Here is a version that compiles:
https://paste.mod.gg/fccxtzieyzez/0
BlazeBin - fccxtzieyzez
A tool for sharing your source code with the world!
But you do NOT want to write your code that way.
I almost reget fixing it up.
ok
thanks
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.
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.
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.