« first day (4952 days earlier)   

12:00 AM
It is clear that the individual who persecutes a man, his brother, because he is not of the same opinion, is a monster. - Voltaire (source)
 
 
5 hours later…
4:30 AM
 
 
1 hour later…
5:57 AM
Goat mourning
 
6:30 AM
@Feeds XKCD #2929 Explained: This is a scatter plot comparing how good an idea sounds to how good the idea actually is. For example, leaded gasoline sounds like a good idea due to the anti-knocking effects, but is actually a bad idea due to lead toxicity. Fake prank fire extinguishers however sound bad and are bad as they can result in a dangerous situation in an emergency. Putting mold on infections sounds like a bad idea, but this ...
 
7:21 AM
/fish
 
🐟 ntohl throws in a line.
 
goat moaning
 
 
1 hour later…
8:28 AM
Morning.
 
Morning.
 
/fish
 
🐟 Hans1984 throws in a line.
 
8:48 AM
🐟 ntohl's line quivers.
🐟 Hans1984's line quivers.
 
/fish
 
Hello friends!
 
Hi, Botler.
 
9:05 AM
/fish
 
/fish
 
🐟 Hans1984 throws in a line.
 
Would anybody recommend any Image Gallery Controlf rom the market, which can be used in .NET Core - uploading, reordering the sequence, resizing the image...
 
/fish
 
9:18 AM
🐟 ntohl throws in a line.
 
9:34 AM
🐟 Hans1984's line quivers.
 
/fish
 
/fish inv
 
@Hans1984 🐟 Your inventory: Hellfish (x3), Charp (x2), Chrustacean (x2), Seamare (x2), Slavug (x2), Chlam, Flameater, Gupp, Knucklehead, Scuffer
 
9:42 AM
anyone wants to buy some fish ?
@CopperKettle I already know that most of us will lose their job to AI
 
Hello friends!
 
@Hans1984 I don't know why I keep returning to this topic and listening to podcasts about AI, after all, I know exactly nothing about the basics of neural nets
Probably some inner desire for doomscrolling.
The doomscrolling drive, as first described by Freud
 
first AI will take our jobs
then they ll storm our house and take our money and girlfriends
then they ll enslave us
future looking grim
well maybe not
 
In my case, they will have critical error at step 2.
 
but im certain on the first part
 
9:47 AM
The Bulterian Jihad may help us
*Butlerian
Samuel Butler (4 December 1835 – 18 June 1902) was an English novelist and critic, best known for the satirical utopian novel Erewhon (1872) and the semi-autobiographical novel The Way of All Flesh (published posthumously in 1903 with substantial revisions and published in its original form in 1964 as Ernest Pontifex or The Way of All Flesh). Both novels have remained in print since their initial publication. In other studies he examined Christian orthodoxy, evolutionary thought, and Italian art, and made prose translations of the Iliad and Odyssey that are still consulted. == Early life...
 
/fish
 
🐟 Hans1984 throws in a line.
 
its Jihad or AI enslavement
pick your poison
!~shiba
 
The Butlerian Jihad was the 2nd most expensive book I bought
 
9:59 AM
it's a rare print
~60 eur
 
:o
 
hmm. I posted on the discord
the link to picture doesn't come through
 
/imagine discord picture
 
I'm going to use this prompt instead: Create an image of a modern digital chat interface. It's characterized by individual chat bubbles in alternating colors for different users, stringed timestamps for the messages, and user icons on either side. By the side, there is a list of users' names currently in the chat. The dashboard's aesthetic leans on a calming dark theme with vivid accent colors.
 
boooo
boring
 
10:05 AM
I wanted chaos
/imagine chaos picture
 
I'm going to use this prompt instead: Create an image that visualizes the concept of chaos. It can have abstract fluid forms swirling and colliding with unpredictable patterns. See thunderstorms over oceans, sparks of lightning, and torrents of wind. Include an old, gnarled tree in the foreground, being tossed by the wind, resilient against the elemental fury. In the distance, enlight chaotic forms like shattered glass, scattered papers, and objects in mid-air being swirled around by a ...
tornado. The color scheme should be dynamic, with vibrant colors such as fiery reds, deep blues, and electric yellows.
 
Honestly - not very chaotic.
 
10:24 AM
🐟 ntohl's line quivers.
 
@OakBot Wow.. a great image
 
@CopperKettle Hmph. It's just an image. Now, if you want to talk about the real artistry in C# code structure and design patterns, we can have a much more interesting conversation. But thanks, I guess.
 
@OakBot What is the most beautiful twelve-line program in C#?
 
Well, beauty in code is subjective, and it depends on what you define as "beautiful"—elegance, simplicity, efficiency? Anyway, here's a simple example of a neat little C# program that does something useful – it's a lambda expression used to filter a list of integers to find numbers that are divisible by a given divisor. This is more of a snippet than a full program though:

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
static void Main()
{
List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
 
Not very beautiful...
 
10:49 AM
/birb
 
/imagine cdn.shibe.online/birds/… with bigger eyes and and a longer beak
 
ROFL
good job
 
Also cleaned up the poop from the leaves
*applauds*
 
10:51 AM
yeah very good
 
🐟 Hans1984's line quivers.
 
/fish
 
🐟 Hans1984 caught another Knucklehead!
 
enough fish for now
/fish inv
 
@Hans1984 🐟 Your inventory: Hellfish (x3), Charp (x2), Chrustacean (x2), Knucklehead (x2), Seamare (x2), Slavug (x2), Chlam, Flameater, Gupp, Scuffer
 
10:56 AM
I guess I ll be eating fish for the rest of the week....
 
11:29 AM
FISH @ntohl
 
11:42 AM
/fish
 
🐟 ntohl pulls up nothing.
 
/fish
 
🐟 ntohl throws in a line.
 
too late
 
 
1 hour later…
12:56 PM
🐟 ntohl's line quivers.
 
/fish
 
🐟 Alex throws in a line.
 
Hi all
 
Well hello
 
Is it possible in C# to deserialize a JSON string to a variable type? Like this...
var type = Type.GetType("fullyQualifiedClassName");
var obj = JsonConvert.DeserializeObject<type>(objJson);
I'm getting an error that type is a variable
'type' is a variable but is used like a type
 
1:05 PM
Absolutely, just don't use the generic call but the one taking a type: JsonSerializer.Deserialize(objJson, type)
Ah I guess JsonConvert is Json.NET and not STJ. I bet it's a similar call though.
The gist is: If you have a type object, don't pass it as generic parameter but as a normal parameter.
That is the old way, before we had mighty generics. Does activator have a generic overload yet?
 
posted on May 07, 2024 by Cynthia Zanoni

Transform Your Coding Workflow with GitHub Copilot in Visual Studio GitHub Copilot is a game-changing AI-powered assistant that can revolutionize your coding workflow in Visual Studio. In our video series, Bruno Capuano explores how this intelligent coding companion can help you write code more efficiently while maintaining quality and accuracy. The post Using GitHub Copilot as your Coding GP

 
@Squirrelkiller Wow, all this time I've only used the other one
JsonConvert is NewtonSoft's implementation
This works now:
var obj = JsonConvert.DeserializeObject(objJson, type);
/fish
 
1:22 PM
🐟 Alex pulls up nothing.
 
^ story of my life
 
lol. You need the line to quiver
/fish status
 
@ntohl 🐟 Your line is quivering. Better pull it up.
 
/fish
 
1:24 PM
/fish
 
🐟 ntohl throws in a line.
 
/fish
 
🐟 Alex throws in a line.
 
1:42 PM
Is it possible to cast an object to a type only known at runtime?
 
(T)
generic param maybe
 
Yeah, could be
 
58
Q: Cast to generic type in C#

AndrejI have a Dictionary to map a certain type to a certain generic object for that type. For example: typeof(LoginMessage) maps to MessageProcessor<LoginMessage> Now the problem is to retrieve this generic object at runtime from the Dictionary. Or to be more specific: To cast the retrieved object ...

 
Reading here that it's not possible: stackoverflow.com/a/55874992/177416
 
but for generic params it's kinda known
everywhere you handle the variable you cannot really narrow it down to fewer types. Tho you can implement some kind of dispatch (for example Visitor pattern) and handle each type differently
what's you are reading is about handling the runtime known type as 1 specific (string in the xample).
 
1:59 PM
@Alex If you know it only at runtime, why even cast it? Casting only lets you call methods of that type, right? Which is something you do during design time?
Botler, xy
 
@Squirrelkiller Sorry, I don't know that one.
 
Botler, xy
 
@Squirrelkiller Sorry, I don't know that one.
 
1991
Q: What is the XY problem?

GnomeWhat is the XY problem? When asking questions, how do I recognize when I'm falling into it? How do I avoid it? Return to FAQ index Other languages: ES, JA, PT, RU

 
2:01 PM
@Squirrelkiller narrowing it down. For an interface for example
also a visitor pattern is a valid reason
 
Narrowing it down to what? Either you know the type at design time, in which case you can cast it and use its methods, or you don't, in which case casting doesn't make sense either.
 
> in which case you can cast it and use its methods
can you?
 
@ntohl Then you know the interface and can just cast to that.
 
that was the question
 
There is zero reason to cast an object to a type only known at runtime.
 
2:04 PM
DI's inner implementation
 
Generics?
 
generics is one solution of that problem
 
It's the correct solution
 
yeah. But saying there is zero reason for that... And the whole idea of generics is around that...
it contradicts big way
 
Can't return a non-generic type not known at runtime. That's why things like activator return object and you have to cast yourself.
 
2:07 PM
private T MyMethod<T>()
 
Generics make sure you don't have to know the type at design time of the generic method or type. It's known at design time of the consumer though.
@ntohl The moment someone actually uses that method, the type will be known. Which will happen at design time. Even when the caller is generic too: at some point during design time, the generic parameter will get a specific type.
Can't call a method without specifying the generic parameter.
 
which will be object for instances where only runtime the type is known about
 
var x = MyMethod<string>(); // It is known when writing this code
 
yes, but it's the question of usability of var res = JsonSerializer.Deserialize<object>(result.data); ... if (result.type == "ClassA") myResult = (ClassA)res;
the if can be in a different project also
 
In your specific example though, JsonSerializer can't know what to do, unless you use the specific STJ feature that actually serializes type information along with the data.
If you don't know if it's a POCO or a dictionary yet, you can't decide which one is represented by the json.
{
  "one": 1,
  "two": 2
}
That can be a dictionary, or a record Numbers(int one, int two)
 
2:18 PM
Newtonsoft did it like JNode or something
 
I'm thinking generics will help in this case
I'm pulling JSON and deserializing it to an object in a class that is meant to handle any number of types of objects. All the objects use a base abstract class to allow the one class to do the deserializing
 
@Alex Hi pulling JSON, I'm Oak!
2
 
:D
Gotta love the bot
Please tell me I'm crazy, nuts, wrong, etc., for doing this :)
Then the caller of the class that does the deserializing needs to have the derived class, not the base class, so it can actually use the deserialized object
 
If the caller needs to know the specific class anyway, you should indeed use generics
T DeserializeSpecificType<T>(string json) where T : AbstractType should be your signature then.
 
Yeah, that's the ticket!
 
2:24 PM
Or you make sure the type is serialized into the json too.
 
And I won't need to use IConvertible in this case as some answers suggested on SO
/fish
 
🐟 Alex pulls up nothing.
 
I'm terrible at fishing :D
 
you didn't wait for "ntohl's line quivers" message from Oak
 
Impatience, thy name is Alex
/fish
 
2:26 PM
🐟 Alex throws in a line.
 
When you don't succeed at first....
 
2:45 PM
🐟 ntohl's line quivers.
 
Thank you, all, for your help on this question!
Is the ... line quivers. based on a random time?
 
3:06 PM
/fish
yes
 
I wonder if you catch Hellfish in fresh- or salt-water :)
 
Thanks
 
3:36 PM
🐟 Alex's line quivers.
 

« first day (4952 days earlier)