Subject: The Little Giant Blueberry

From: DIY Gardening <[email-masked]>
Date: Tue, 27 May 2014 10:16:48 -0700

DIY Digest: Gardening Edition
Top Pick From Memorial Day Weekend

Blueberry Giant  Grow Up To 16,0000 Berries Per Plant
========================================================

Want to get fresh produce from you back yard?
No need to trek out to the grocery store just to buy old blueberries. 

One of our readers sent in pics of the most beautiful Home Gardens we've ever seen. 
She told us there is only 1 step needed for DIY Gardening Success...

1 Step Way to do it >> http://www.gemunisir.com/redeem/bonus/plant/ASOTV.html

to modify your message status - write Alert System Notifications
at: 1107 Valeria Dr.|Marion|Texas,,, 78124
-or- http://www.gemunisir.com/39fhjg/sno.sj4jkk

var lifeInSeconds = (DateTime.Now.Ticks - then.Ticks)/TickFactor;
In the Christian way of calculating age in years:

var then = ... // Then, in this case the birthday
var now = DateTime.UtcNow;
int age = now.Year - then.Year;
if (now.AddYears(-age) < then) age--;
In finance there is a similar problem when calculating something often referred to as the Day Count Fraction, which roughly is the amount of years for a given period. And the age issue is really a time measuring issue.

Example for the actual/actual (counting all days "correctly") convention:

DateTime start, end = .... // Whatever, assume start is before end

double startYearContribution = 1 - (double) start.DayOfYear / (double) (DateTime.IsLeapYear(start.Year) ? 366 : 365);
double endYearContribution = (double)end.DayOfYear / (double)(DateTime.IsLeapYear(end.Year) ? 366 : 365);
double middleContribution = (double) (end.Year - start.Year - 1);

double DCF = startYearContribution + endYearContribution + middleContribution;
Another quite common way to measure time generally is by "serializing" (the dude who named this date convention must seriously have been trippin'):
DateTime start, end = .... // Whatever, assume start is before end
int days = (end - start).Days;
I wonder how long we have to go before a relativistic age in seconds becomes more useful than the rough approximation of earth-around-sun-cycles during ones lifetime so far :) Or in other words, when a period must be given a location or a function representing motion for itself to be valid :)
I've heard vague rumours that this is terifically slow. Anyone know?   Orion Edwards Oct 15 '08 at 1:31
269	  Enumerating an enum with 52 values 100000 times: 3884ms Enumerating an int[] with 52 values 100000 times: 99ms yes, far slower tha@Hainesy - haha! eds more than a syntax hilighter. it needs a syntax checker. fixed.   jop Aug Is there any way it can be enumerated in the order of how the values are declared? Both GetValues and GetNames return them ordered by the numeric value :/   David Sep 13 '11 at 14:46
@TheSoftwareJedi nice benchmark, though I think it's because ints get special optimization which .NET Enums can never dream of.   Luka Ramishvili Nov 11 '11 at 6:55
This doesn't work if you have duplicate values in the enumerator list.   Jessy Jun 17 '12 at 3:50
@Jessy I can't compile an enum with duplicate values, can you?   PandaWood Sep 6 '12 at 4:04
@PandaWood enum E {A = 0, B = 0}   Jessy Sep 6 '12 at 15:44
@Jessy, oh right, I'm always using enum E { bla, bla2} where enum E { bla, bla} doesn't compile. Which is what the questioner is doing as well, so using int like you've done probably doesn't really apply here, since there's unlikely to be any purpose to enumerating an enum with raw ints - it's the list of string names I think we're all after   PandaWood Sep 11 '12 at 2:43@Jessy: I'd suppose Code Complete had at-least-two-distinctive-values enum in mind. Your sample is possible, but not advisable.   Peter Ivan Oct 23 '12 at 5:40
@Jessy, you have to see a context. In case of foreach you don't need such limits, and kudos for you if you can enumerate arbitrary enum with for loop (in such case nothing will really help you, e.g. enum foo { abc = 1, abc = 17 }). But if you really want first, and last -- LINQ First and Last will do the trick.   greenoldman Dec 1 '12 at 23:00Another point to note is that a lot of that 4 seconds will be in the Enum.Getvalues bit. Get that first, and once, and what do you get then?   Immortal Blue Feb 5 '13 at 19:12
The compile-time return type of GetValues is System.Array. If you foreach directly, like above, you will get the non-generic IEnumerable implementation of System.Array. This involves boxing all the enum values into an object box, which is then unboxed by the cast present in your foreach. If instead you use foreach (var suit in (Suit[])Enum.GetValues(typeof(Suit))) you don't get any boxing. The cast from Array to Suit[] is one simple reference conversion and happens only once. I can't beleive 181 people upvoted @TheSoftwareJedi's comment on performance without mention of this.   Jeppe Stig Nielsen Apr 15 '13 at 17:57
@JeppeStigNielsen, Just did a test with your method, it indeed is basically identical performance to int[] if you perform the cast only once. I pulled the Enum.GetValues outside of the loops in both cases. The int[] was about 60 milliseconds. Likewise with the cast. Without the cast, it was just over a second. 50 values, 100,000 iterations over those 50 values.   Travis May 2 '13 at 19:35  @Jessy if you need all the names (including the ones with duplicate values), maybe try Enum.GetNames in conjunction with Enum.Parse. It's going to be a little slow though, I recommend doing it once during initialization (or the first time it's needed) and caching the results into an array.   BrainSlugs83 Aug 13 '13 at 2:05 @David no, the order they are declared in is lost at compile time. You could instead add a custom attribute to each enum specifying what order you want them in, and then reorder your array based on the value of that custom attribute.   BrainSlugs83 Aug 13 '13 at 2:07
how about EnumSet.allOf ?   Kalpesh Soni Aug 27 '13 at 21:02I just want to point out that this, unfortunately won't work in silverlight, since the silverlight library don't comprise enum.GetValues. You have to use reflection in this case.   Giacomo Tagliabue Oct 17 '13 at 5:50
@Jessy this does work in case of duplicate situations like enum E {A = 0, B = 0}. Enum.GetValues results in two values being returned, though they are the same. E.A == E.B is true, so there is not distinction. If you want individual names, then you should look for Enum.GetNames.   nawfal Nov 7 '13 at 9:25