LordKalma (CT7ALW)
Smart enums, inheritance and "siblings" behaving weirdly and I don't understand why.
So, I'm using
Ardalis.SmartEnum
to create some smart enums with data members.
I found myself having a lot of boilerplate, so I came up with the following code:
This code works. However, note ModeBase<TEnum> : SmartEnum<TEnum, int>
.
What I found is that this code doesn't work if I don't template ModelBase
and I don't know why.
[continues in the comments]19 replies
❔ Capturing value-types by value (i.e., making a copy) in λs. Or rather, using a Span<T> in a λ.
I have some code using a
Span<T>
. I wanted to use some LINQ with it (e.g. the Enumerable.Range.Select
method), but whenever I try to use the Span<T>
object inside a lambda, I get the error CS8175:
Error CS8175 Cannot use ref local <mySpanVariable>
inside an anonymous method, lambda expression, or query expression.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs8175
How can I work around this?11 replies
❔ App.config: "special one" for testing/debugging
Hello,
I'm making a small console application that needs some configuration (an API key, and a list of "filters"). I thought of saving that kind of configuration in an
App.config
file. Question is: how can I just have a "template" file for VCS storage, and have a "local" one filled with my secrets for testing/debugging?18 replies
❔ Deserialize serial data to struct (port from C)
Hello,
I'm not sure how you do this in C#:
I have this code I'm porting to C#. It's basically a stream from a serial port that needs to be de-serialized into a struct.
This is the C code for the struct:
You can explore the code better if you want on this header file and this C file. This is a bit of an on-going work that's a bit rough. Since I want to move to C# and all the code is doing is writing and reading to serial, I thought I could just do away with the base C(++) library.
What tools in C# do you use to define and de-serialize a
struct
like this?
Thanks7 replies