Browsing 7239 questions and answers with Jon Skeet
Sounds like you probably want ArgumentException, or ArgumentNullException, or ArgumentOutOfRangeException depending on the precise nature. (The latter exceptions are subtypes of the first.) more 2/13/2014 1:40:51 PM
I believe it's to do with the version of the CLR being used. On the CLR prior to v4, the culture information being used did have the time separator as .. On CLR v4+, it's :. I don't know why... presumably CLR v4+ is reading the regional... more 2/13/2014 11:19:37 AM
It's somewhat safe. Or rather, it's as safe as if you had a variable which isn't used after the method call anyway. An object is eligible for garbage collection (which isn't the same as saying it will be garbage collected immediately)... more 2/13/2014 10:03:12 AM
You're calling Add, but not using the result at all. Add doesn't change the value - it returns a new value. You want: TotalWorkHours = TotalWorkHours.Add(Interval[i]); Or more idiomatically, IMO: TotalWorkHours += Interval[i]; Or... more 2/13/2014 9:48:37 AM
But I want to generate a random angle from range [a;b], excluding everything in the middle. Assuming b is greater than a, that's just a matter of getting a value in the range [0, b - a) and then adding a: float randomAngle = (float)... more 2/13/2014 9:43:37 AM
I suspect you're looking for Any, which allows you to check whether any item in a sequence (the arrays in this case) matches a predicate: var query = from item in allItems where itemColour.Any(c => c.Contains(item.colour)) ... more 2/13/2014 9:40:21 AM
You're using the local default string conversion from DateTime (I assume) to string, and then hoping that's valid for SQL. Additionally, your code has a SQL injection attack vulnerability. Both of these can be fixed - and your code... more 2/13/2014 7:31:37 AM
The user's time zone and the user's culture are entirely separate matters. It's not clear where this code is running, but basically you want to use the appropriate CultureInfo, and then you can use DateTime.TryParse specifying the... more 2/12/2014 3:54:14 PM
This looks suspicious to me: int x = generator.nextInt(rows); int y = generator.nextInt(columns); Given that an x value specifies a column usually, I suspect you want: int x = generator.nextInt(columns); int y =... more 2/12/2014 12:13:30 PM
You just use the get method: // 2nd element; Java uses 0-based indexing almost everywhere Matrices element = list.get(1); What you do with the Matrices reference afterwards is up to you - you've shown the constructor call, but we don't... more 2/12/2014 9:00:38 AM