Click here to Skip to main content
15,439,290 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
mvaMircea Neacsu4-Apr-22 13:20 
GeneralRe: PathYetAnotherMakeUniqueName Pin
Cpichols6-Apr-22 1:21
MemberCpichols6-Apr-22 1:21 
GeneralRe: PathYetAnotherMakeUniqueName Pin
deepok14-Apr-22 19:35
Memberdeepok14-Apr-22 19:35 
GeneralRe: PathYetAnotherMakeUniqueName Pin
ShawnVN6-Apr-22 7:16
MemberShawnVN6-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) PinPopular
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
MemberPaulo Zemek22-Feb-22 20:24 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
Super Lloyd10-Mar-22 12:48
MemberSuper Lloyd10-Mar-22 12:48 
GeneralRe: Null Strikes Again! (even with C# special operators) Pin
jschell8-May-22 9:17
Memberjschell8-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
Memberjeron17-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
Memberjeron17-Jan-22 6:43 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
deepok14-Apr-22 5:44
Memberdeepok14-Apr-22 5:44 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
jeron14-Apr-22 5:53
Memberjeron14-Apr-22 5:53 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
deepok14-Apr-22 5:58
Memberdeepok14-Apr-22 5:58 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Alister Morton6-Apr-22 3:59
MemberAlister Morton6-Apr-22 3:59 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Super Lloyd7-Jan-22 11:56
MemberSuper 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
MemberSuper Lloyd7-Jan-22 12:05 
GeneralRe: BuT cAn ThEY RuN DoOM? Pin
Ron Anders7-Jan-22 14:57
MemberRon 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.