Click here to Skip to main content
15,867,895 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralPathYetAnotherMakeUniqueName Pin
Brisingr Aerowing4-Apr-22 7:56
professionalBrisingr Aerowing4-Apr-22 7:56 
GeneralRe: PathYetAnotherMakeUniqueName Pin
raddevus4-Apr-22 10:14
mvaraddevus4-Apr-22 10:14 
GeneralRe: PathYetAnotherMakeUniqueName Pin
Mircea Neacsu4-Apr-22 13:20
Mircea Neacsu4-Apr-22 13:20 
GeneralRe: PathYetAnotherMakeUniqueName Pin
Cpichols6-Apr-22 1:21
Cpichols6-Apr-22 1:21 
GeneralRe: PathYetAnotherMakeUniqueName Pin
deepok14-Apr-22 19:35
deepok14-Apr-22 19:35 
GeneralRe: PathYetAnotherMakeUniqueName Pin
ShawnVN6-Apr-22 7:16
ShawnVN6-Apr-22 7:16 
GeneralNull Strikes Again! (even with C# special operators) Pin
raddevus22-Feb-22 11:25
mvaraddevus22-Feb-22 11:25 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
Jon McKee22-Feb-22 11:44
professionalJon McKee22-Feb-22 11:44 
C#
sqliteProvider.command.Parameters.AddWithValue("$screenName", (object) task.screenName ?? System.DbNull.Value);
That should work. C# won't coerce a type (even if it's valid) to a type not present in the expression. Here it sees string and DBNull, so even though object is a valid base for them, object isn't available unless you explicitly opt-in. That's my understanding at least Thumbs Up | :thumbsup:

EDIT: You might need a ? for the cast. Unsure since I'm still on an older version of C# so I haven't had to deal with that new stuff yet.
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
raddevus22-Feb-22 11:50
mvaraddevus22-Feb-22 11:50 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
raddevus22-Feb-22 11:53
mvaraddevus22-Feb-22 11:53 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
Paulo Zemek22-Feb-22 20:24
mvaPaulo Zemek22-Feb-22 20:24 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
Super Lloyd10-Mar-22 12:48
Super Lloyd10-Mar-22 12:48 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
jschell8-May-22 9:17
jschell8-May-22 9:17 
GeneralBuT cAn ThEY RuN DoOM? Pin
honey the codewitch7-Jan-22 6:14
mvahoney the codewitch7-Jan-22 6:14 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
jeron17-Jan-22 6:25
jeron17-Jan-22 6:25 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
honey the codewitch7-Jan-22 6:33
mvahoney the codewitch7-Jan-22 6:33 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
jeron17-Jan-22 6:43
jeron17-Jan-22 6:43 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
deepok14-Apr-22 5:44
deepok14-Apr-22 5:44 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
jeron14-Apr-22 5:53
jeron14-Apr-22 5:53 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
deepok14-Apr-22 5:58
deepok14-Apr-22 5:58 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Alister Morton6-Apr-22 3:59
Alister Morton6-Apr-22 3:59 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Super Lloyd7-Jan-22 11:56
Super Lloyd7-Jan-22 11:56 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
honey the codewitch7-Jan-22 12:17
mvahoney the codewitch7-Jan-22 12:17 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Super Lloyd7-Jan-22 12:05
Super Lloyd7-Jan-22 12:05 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Ron Anders7-Jan-22 14:57
Ron Anders7-Jan-22 14:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.