Posts

Showing posts from April 11, 2019

Get elementary values from a flagged enum

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0; 5 $begingroup$ I created a little function that returns the elementary values from a flagged enum. By "elementary" I mean the values that are powers of 2, excluding any combined enum values. I was a bit surprised I couldn't find a buit-in method for this in .Net (or I missed it). Let's take this flagged enum: [Flags] public enum WeekDay Tuesday Since the binary representation of its values looks as follows... 1 10 100 1000 10000 100000 1000000 1100000 11111 ...I came up with this function to extract the elementary values: public IEnumerable<TEnum> GetElementaryValues<TEnum>() where TEnum: Enum return Enum.GetValues(typeof(TEnum)) .Cast<TEnum>() .Where(v => var intValue = Convert.ToInt64(v); var binary = Convert.ToString(intValue, 2); return !binary.Skip(1).Any(...

What is the difference between “shut” and “close”?

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0; 7 6 It is obvious that shut and close are very similar in meaning. However, while learning English as non-native (a long time ago) the teacher underlined that the two words are not identical in meaning. I was unable to find a "clear" explanation about this difference yet - so I am still confused. I found: the definitions of the words; how the words are similar; I did not find: how are these words different. Edit: Based on the answers and on the comments, is it safe to assume that there is no "general" rule about when to use "shut" and "close"? And that one must learn the "correct" verb for each situation separately? word-meaning difference share | improve this question edited Mar 14 at 12:13 virolino asked Mar 13 at 7:05 vir...