Browsing 7239 questions and answers with Jon Skeet
It looks like VB has built-in support for DataTable. Here's a short but complete example: Option Strict On Imports System Imports System.Data Imports System.Linq Public Class LinqTest Shared Sub Main() Dim table as... more 11/18/2015 3:53:53 PM
Don't try to escape anything - just use parameterized SQL. You may not care about SQL injection attacks now, but you will at some point... and by using parameterized SQL for your values, you'll remove both the escaping and injection attack... more 11/18/2015 3:18:36 PM
Okay, so it sounds like you just need to detect whether or not it's a NaN value: double value = DataContainer.GetValue(ColKeyId, index); if (double.IsNaN(value) || double.IsInfinity(value) || (decimal) value != (decimal)... more 11/18/2015 10:00:24 AM
There's nothing in the framework, but you can use MoreLINQ's Batch method: foreach (var sublist in myList.Batch(5)) { // sublist has up to 5 elements } (On the final iteration, it will have just 3 elements.) more 11/17/2015 4:47:56 PM
There's a method Type.GetGenericTypeArguments that has been available for ages. I suspect that at least in most cases, the two are equivalent. I suspect that the property is just part of the reflection API design in .NET 4.5 (to use... more 11/17/2015 2:00:33 PM
Well you need to set the display name, I suspect. Currently you're calling String.replace which creates a new string - but as strings as immutable, the existing display name won't be changed. I suspect you really want: for (Contact... more 11/16/2015 7:22:52 PM
This is to be expected, given differences in culture. From the string.CompareTo(string) documentation: This method performs a word (case-sensitive and culture-sensitive) comparison using the current culture. For more information about... more 11/16/2015 1:16:27 PM
Think of the string as a sequence of characters. A sequence contain at least one duplicate if the count of the distinct elements is not equal to the overall count of the elements. In other words: bool containsDuplicates =... more 11/14/2015 10:21:00 PM
It's a bug in the compiler - at least in Roslyn version 1.0.0.50618. From section 8.5.2 of the C# 5 specification: A local-constant-declaration declares one or more local constants. local-constant-declaration: ... more 11/13/2015 2:43:45 PM
You'll currently always see "That is an invalid choice" unless x is 4... because the final if/`else is disconnected from all the rest. You could change it to use else if everywhere, like this: if (x == 1) { ... } else if (x == 2) { ... more 11/13/2015 1:30:52 PM