Click here to Skip to main content
15,908,901 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Need a good name for an extension method Pin
Marc Clifton14-Feb-17 5:19
mvaMarc Clifton14-Feb-17 5:19 
GeneralRe: Need a good name for an extension method Pin
User 1106097914-Feb-17 5:34
User 1106097914-Feb-17 5:34 
GeneralRe: Need a good name for an extension method Pin
Mark_Wallace14-Feb-17 5:07
Mark_Wallace14-Feb-17 5:07 
GeneralRe: Need a good name for an extension method Pin
User 1013254614-Feb-17 5:07
User 1013254614-Feb-17 5:07 
GeneralRe: Need a good name for an extension method Pin
theoldfool14-Feb-17 5:21
professionaltheoldfool14-Feb-17 5:21 
GeneralRe: Need a good name for an extension method Pin
Member 1286378714-Feb-17 6:31
Member 1286378714-Feb-17 6:31 
QuestionRe: Need a good name for an extension method Pin
Jeremy Falcon14-Feb-17 9:48
professionalJeremy Falcon14-Feb-17 9:48 
GeneralRe: Need a good name for an extension method Pin
BillWoodruff15-Feb-17 0:53
professionalBillWoodruff15-Feb-17 0:53 
Hi, Marc,

I am a little wary of extension methods on 'Int32 because of compiler error #CS0023
C#
<CS0023 Operator '-' cannot be applied to operand of type 'XXXXXX
caused by an attempt to use/call the method on a negative integer; while this can be worked around by putting the negative value in parens; I find that tedious.
C#
var x = -100.SomeExtension(10);    // will not compile
var y = (-100).SomeExtension(10);  // will compile
var z = 100.SomeExtension(10);     // will compile
I regret to say this same error occurs in VS 2017, using the latest FrameWork version.

I assume this is an operator execution precedence issue ?

I have not evaluated whether this error occurs with other numeric Types; I hypothesize it will.

cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008


modified 15-Feb-17 11:56am.

General"Hackathons" and related "hack" stuff Pin
richp66914-Feb-17 2:55
professionalrichp66914-Feb-17 2:55 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Eddy Vluggen14-Feb-17 3:01
professionalEddy Vluggen14-Feb-17 3:01 
GeneralRe: "Hackathons" and related "hack" stuff Pin
CDP180214-Feb-17 3:13
CDP180214-Feb-17 3:13 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Eddy Vluggen14-Feb-17 3:22
professionalEddy Vluggen14-Feb-17 3:22 
GeneralRe: "Hackathons" and related "hack" stuff Pin
CDP180214-Feb-17 3:27
CDP180214-Feb-17 3:27 
GeneralRe: "Hackathons" and related "hack" stuff Pin
richp66914-Feb-17 3:22
professionalrichp66914-Feb-17 3:22 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Daniel Pfeffer14-Feb-17 3:04
professionalDaniel Pfeffer14-Feb-17 3:04 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Mark_Wallace14-Feb-17 3:12
Mark_Wallace14-Feb-17 3:12 
GeneralRe: "Hackathons" and related "hack" stuff Pin
CDP180214-Feb-17 3:20
CDP180214-Feb-17 3:20 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Mark_Wallace14-Feb-17 5:03
Mark_Wallace14-Feb-17 5:03 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Daniel Pfeffer14-Feb-17 3:25
professionalDaniel Pfeffer14-Feb-17 3:25 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Sander Rossel14-Feb-17 20:47
professionalSander Rossel14-Feb-17 20:47 
GeneralRe: "Hackathons" and related "hack" stuff Pin
User 1013254614-Feb-17 3:07
User 1013254614-Feb-17 3:07 
GeneralRe: "Hackathons" and related "hack" stuff Pin
richp66914-Feb-17 3:25
professionalrichp66914-Feb-17 3:25 
GeneralRe: "Hackathons" and related "hack" stuff Pin
User 1013254614-Feb-17 3:38
User 1013254614-Feb-17 3:38 
GeneralRe: "Hackathons" and related "hack" stuff Pin
Nelek14-Feb-17 3:38
protectorNelek14-Feb-17 3:38 
GeneralRe: "Hackathons" and related "hack" stuff Pin
User 1013254614-Feb-17 3:41
User 1013254614-Feb-17 3:41 

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.