it’s raining outside
it’s raining outside
Explore posts from servers
CC#
Created by it’s raining outside on 11/25/2024 in #help
best libraries for a journalling app (windows only)
hey guys. so i wanted to make a journalling app myself that'll keep me more accountable in the future. sure, i could use a markdown editor like obsidian or vscode's built-in markdown viewer, but i'm a developer and the best part about being a developer is remaking stuff that already exists just because you can aside from the backstory, what would be good libraries for this sort of thing? looking for a relatively gentle learning curve where i can get a grasp of the basics and get started easily. open to all suggestions and i need something to do over these coming weeks. this will probably be only a windows project, as my friend group only uses windows which is who i'll probably distribute this to. lemme know what you think 👍🏽
78 replies
CC#
Created by it’s raining outside on 10/25/2024 in #help
code builds but hangs while running
code: https://paste.pythondiscord.com/KTVQ when i build it in release, everything works fine. but when i run in release, it just hangs and does nothing, even though all i'm doing is this:
class Program
{
// ... <- nothing up here is run

static void DisplayHelp()
{
string help = """
This is a test help screen.

What do you think?
""".Trim();

Console.WriteLine(help);
}

static void Main()
{
DisplayHelp();
}
}
class Program
{
// ... <- nothing up here is run

static void DisplayHelp()
{
string help = """
This is a test help screen.

What do you think?
""".Trim();

Console.WriteLine(help);
}

static void Main()
{
DisplayHelp();
}
}
203 replies
CC#
Created by it’s raining outside on 10/15/2024 in #help
how do stacks, lists, arrays, etc have a collection expression?
is it part of the compiler or is there a special function or attribute you can give code in order for it to work that way?
5 replies
CC#
Created by it’s raining outside on 10/11/2024 in #help
what are hashtags for in C#?
i've written C# for a month and have zero idea what these hashtag symbols are for. like #define - what does that do?
21 replies
CC#
Created by it’s raining outside on 10/3/2024 in #help
"Object reference not set to an instance of an object"
code: https://github.com/axololly/chess/tree/main/Board.cs#L1073 not sure why this is happening. i changed the Board from a class to a struct so it's no longer heap allocated (used in an engine, so these things matter) and now it's raising weird errors like this
59 replies
CC#
Created by it’s raining outside on 10/3/2024 in #help
✅ this error makes no sense
getting a null reference exception here:
static Evaluation eval = new();
static Evaluation eval = new();
and that traces to this:
mgTable[pc][sq] = mgValue[p] + GetMGTable(p)[sq];
mgTable[pc][sq] = mgValue[p] + GetMGTable(p)[sq];
and THAT traces to this:
static int[][] mgTable = new int[12][];
static int[][] mgTable = new int[12][];
am i dumb or is this just not how you construct an array like that?
7 replies
CC#
Created by it’s raining outside on 9/27/2024 in #help
✅ how do i update my nuget package?
google thinks i want to update it in my project, which i do also want to do on the command line, but how do i publish a new version of my nuget package?
34 replies
CC#
Created by it’s raining outside on 9/26/2024 in #help
✅ vscode telling me some weird errors
No description
10 replies
CC#
Created by it’s raining outside on 9/24/2024 in #help
✅ how do i publish my .NET project?
so i made this chess thingy (do check it out, i spent a month on it) and I want to publish it online so i can primarily use it in my other projects. how exactly do i go about this? i'm using vscode btw - vs runs like shit and doesn't correct my code properly. command line would be preferred.
74 replies
CC#
Created by it’s raining outside on 9/22/2024 in #help
✅ impossible error
so i'm using a Stack<Move> for my chess board's move history. it somehow managed to raise an out-of-bounds error with the line being directly correlated to this line:
moveHistory.Push(move); // Index was outside the bounds of the array.
moveHistory.Push(move); // Index was outside the bounds of the array.
i have zero fucking clue what this is caused by. here's the rest of my code: https://mystb.in/4b14af70b18dc60777 (line 225-250)
18 replies
CC#
Created by it’s raining outside on 9/22/2024 in #help
null check raising errors
i come from python and my first interpretation was that they can work like decorators, but that's clearly not the case. my question is how do i modify class data with an attribute? like how in python you can decorate a class like this:
def change(name, value):
def wrapper(cls):
setattr(cls, name, value)
return cls

return wrapper

# ...

@change("num", 4)
class MyClass:
def __init__(self):
self.num = 10

mc = MyClass()
print(mc.num) # prints 4 and not 10
def change(name, value):
def wrapper(cls):
setattr(cls, name, value)
return cls

return wrapper

# ...

@change("num", 4)
class MyClass:
def __init__(self):
self.num = 10

mc = MyClass()
print(mc.num) # prints 4 and not 10
how would i do this in C#?
112 replies
CC#
Created by it’s raining outside on 9/22/2024 in #help
✅ Inconsistent accessibility error - no idea where this came from
Full error:
Inconsistent accessibility: parameter type 'Argument[]' is less accessible than method 'CLI.ArgParser(string[], Argument[])'
Inconsistent accessibility: parameter type 'Argument[]' is less accessible than method 'CLI.ArgParser(string[], Argument[])'
Code:
namespace CommandLine
{
public struct CLI
{
public static Dictionary<string, string> ArgParser(string[] argsFromCLI, Argument[] validArguments)
{
int[] validArgIndexes = Enumerable
.Range(0, argsFromCLI.Length)
.Where(n => validArguments.Contains(argsFromCLI[n]))
.ToArray();

Dictionary<string, string> convertedArgs = [];

for (int x = 0; x < validArgIndexes.Length - 1; x++)
{
int firstIndex = validArgIndexes[x];
int secondIndex = validArgIndexes[x + 1];

string first = argsFromCLI[firstIndex];
string other = string.Join(" ", argsFromCLI[(firstIndex + 1) .. secondIndex]);

convertedArgs.Add(first, other);
}

return convertedArgs;
}
}
}
namespace CommandLine
{
public struct CLI
{
public static Dictionary<string, string> ArgParser(string[] argsFromCLI, Argument[] validArguments)
{
int[] validArgIndexes = Enumerable
.Range(0, argsFromCLI.Length)
.Where(n => validArguments.Contains(argsFromCLI[n]))
.ToArray();

Dictionary<string, string> convertedArgs = [];

for (int x = 0; x < validArgIndexes.Length - 1; x++)
{
int firstIndex = validArgIndexes[x];
int secondIndex = validArgIndexes[x + 1];

string first = argsFromCLI[firstIndex];
string other = string.Join(" ", argsFromCLI[(firstIndex + 1) .. secondIndex]);

convertedArgs.Add(first, other);
}

return convertedArgs;
}
}
}
5 replies
CC#
Created by it’s raining outside on 9/21/2024 in #help
✅ while loop on cpu
is there a type of while loop that doesn't hammer the cpu with checks? like when i type a character, THATS when it updates, instead of as many times as it possibly can, because it slows down my pc and i dont get these issues with other CLI tools (eg. python repl)
37 replies
CC#
Created by it’s raining outside on 9/21/2024 in #help
✅ when programming a CLI in C#...
1. how can i open my own CLI window like how starting the python repl works? 2. how can i take input with a string predecessor? i want to do >>> ... but there isnt a way to get an input on the same line as text, as far as ive seen
23 replies
CC#
Created by it’s raining outside on 9/21/2024 in #help
how do i rotate part of a multidimensional matrix?
i have a 2D matrix representing a rubik's cube (figured that a 3D matrix would be both quite difficult and a massive overhead) and i want to rotate just one of the inner 1D matrices to rotate just one face of the side. how would i do this?
45 replies
CC#
Created by it’s raining outside on 9/19/2024 in #help
✅ set "dotnet run" to always run in release
how do i do that?
79 replies
CC#
Created by it’s raining outside on 9/19/2024 in #help
good GUI for a chess game?
i looked into XAML and it looks like a right pain to learn. godot i still dont understand how to use, havent looked into monogame. hit me with your best gui options for a chess game
7 replies
CC#
Created by it’s raining outside on 9/16/2024 in #help
✅ Making a chess program. Why is this happening?
No description
85 replies
CC#
Created by it’s raining outside on 8/26/2024 in #help
✅ how do i override built-in methods?
i come from python where you can override methods in a class to work a certain way. for example, for use in the == operator, you can override a class to modify the behaviour of the __eq__ method which checks if two objects are equal. if i wanted to do an XOR on a class that holds an internal value, how can i override it so it works on the internal value instead of the class itself?
20 replies
CC#
Created by it’s raining outside on 8/25/2024 in #help
✅ ternary select between static classes
i have two static classes like this
public static class WhitePieces
{
...
}
public static class BlackPieces
{
...
}
public static class WhitePieces
{
...
}
public static class BlackPieces
{
...
}
and i'm trying to select between them like this
var pieceClass = sideAttacking == Colour.White ? WhitePieces : BlackPieces;
var pieceClass = sideAttacking == Colour.White ? WhitePieces : BlackPieces;
and i'm getting this error:
'WhitePieces' is a type, which is not valid in the given context
'WhitePieces' is a type, which is not valid in the given context
why is that?
2 replies