Click here to Skip to main content
15,884,388 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.

 
GeneralHow many values between 0 and 0? Pin
raddevus16-Dec-19 5:59
mvaraddevus16-Dec-19 5:59 
GeneralRe: How many values between 0 and 0? Pin
Richard Deeming16-Dec-19 8:49
mveRichard Deeming16-Dec-19 8:49 
GeneralRe: How many values between 0 and 0? Pin
raddevus16-Dec-19 8:58
mvaraddevus16-Dec-19 8:58 
GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz16-Dec-19 9:05
TheGreatAndPowerfulOz16-Dec-19 9:05 
GeneralRe: How many values between 0 and 0? Pin
raddevus16-Dec-19 9:21
mvaraddevus16-Dec-19 9:21 
GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz16-Dec-19 10:05
TheGreatAndPowerfulOz16-Dec-19 10:05 
GeneralRe: How many values between 0 and 0? Pin
raddevus16-Dec-19 10:16
mvaraddevus16-Dec-19 10:16 
GeneralRe: How many values between 0 and 0? Pin
Richard Deeming17-Dec-19 0:28
mveRichard Deeming17-Dec-19 0:28 
TheGreatAndPowerfulOz wrote:
foreach(var item in 1..100)

That code won't work:
CS1579 foreach statement cannot operate on variables of type 'Range' because 'Range' does not contain a public instance definition for 'GetEnumerator'

And if you change it to iterate over a range of an array, the upper-bound is exclusive:
C#
int[] numbers = Enumerable.Range(0, 20).ToArray();
foreach (int i in numbers[1..10])
{
    Console.WriteLine(i);
}

/*
Output:
1
2
3
4
5
6
7
8
9
*/
The start of the range is inclusive, but the end of the range is exclusive, meaning the start is included in the range but the end isn't included in the range.




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz17-Dec-19 5:05
TheGreatAndPowerfulOz17-Dec-19 5:05 
GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz16-Dec-19 9:02
TheGreatAndPowerfulOz16-Dec-19 9:02 
GeneralRe: How many values between 0 and 0? Pin
raddevus16-Dec-19 9:10
mvaraddevus16-Dec-19 9:10 
GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz16-Dec-19 10:07
TheGreatAndPowerfulOz16-Dec-19 10:07 
GeneralRe: How many values between 0 and 0? Pin
raddevus16-Dec-19 10:32
mvaraddevus16-Dec-19 10:32 
GeneralRe: How many values between 0 and 0? Pin
crystalgecko18-Dec-19 23:44
crystalgecko18-Dec-19 23:44 
GeneralRe: How many values between 0 and 0? Pin
kalberts19-Dec-19 0:28
kalberts19-Dec-19 0:28 
GeneralRe: How many values between 0 and 0? Pin
TheGreatAndPowerfulOz19-Dec-19 4:36
TheGreatAndPowerfulOz19-Dec-19 4:36 
GeneralRe: How many values between 0 and 0? Pin
Stuart Dootson19-Dec-19 7:52
professionalStuart Dootson19-Dec-19 7:52 
GeneralRe: How many values between 0 and 0? Pin
raddevus19-Dec-19 8:24
mvaraddevus19-Dec-19 8:24 
GeneralRe: How many values between 0 and 0? Pin
Bohdan Stupak15-Feb-20 5:49
professionalBohdan Stupak15-Feb-20 5:49 
GeneralTo get a %age divide the number by the number of decimal places defined on the column Pin
CHill6013-Dec-19 1:20
mveCHill6013-Dec-19 1:20 
GeneralRe: To get a %age divide the number by the number of decimal places defined on the column Pin
phil.o13-Dec-19 1:38
professionalphil.o13-Dec-19 1:38 
GeneralRe: To get a %age divide the number by the number of decimal places defined on the column Pin
CHill6013-Dec-19 1:42
mveCHill6013-Dec-19 1:42 
GeneralRe: To get a %age divide the number by the number of decimal places defined on the column Pin
Marc Clifton13-Dec-19 2:39
mvaMarc Clifton13-Dec-19 2:39 
GeneralRe: To get a %age divide the number by the number of decimal places defined on the column Pin
Nelek13-Dec-19 3:04
protectorNelek13-Dec-19 3:04 
GeneralRe: To get a %age divide the number by the number of decimal places defined on the column Pin
Marc Clifton13-Dec-19 4:05
mvaMarc Clifton13-Dec-19 4:05 

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.