Browsing 7239 questions and answers with Jon Skeet
Your code is equivalent to: var parameter = new SqlParameter("@mydate", SqlDbType.DateTime); var value = MyDTP01.Value; parameter.Value = value; cmd.Parameters.Add(value); You want to add the parameter, not the value.... more 7/29/2014 8:06:24 AM
What is the reason for the OOM while creating a new string Because you're running out of memory - or at least, the CLR can't allocate an object with the size you've requested. It's really that simple. If you want to avoid the errors,... more 7/29/2014 7:59:33 AM
You're searching for types - so your result is an IEnumerable<Type>. Those Type objects don't implement your interface - instances of the types would implement the interface. So your code is trying to do something a little... more 7/29/2014 6:04:10 AM
There are two aspects to this: Working out the number of days between two dates Personally, I'd use my Noda Time API for this, but you could still use the BCL's DateTime type - subtract one DateTime from the other to get a TimeSpan, and... more 7/28/2014 3:05:50 PM
Here, if tmpCommand's value will change to modelItem.getName() value since it references commandName. No, it won't. The value of tmpCommand is just the value of commandName at the time of the assignment. That's really simple to... more 7/28/2014 2:25:14 PM
Yes, that's because you're creating a ReturnState<object>, which isn't a ReturnState<Person>. Options: Change your PostModerateAttribute to find out the correct return type, and create an instance of that instead. Hard-code... more 7/28/2014 11:46:07 AM
A "does not contain" expression is exactly the same as a "does contain" expression - but wrapped with a unary negation expression. So basically you want: // Code as before var doesNotContain = Expression.Not(contains); return... more 7/28/2014 10:19:47 AM
I'd use LINQ to XML to start with. Something like this: var doc = XDocument.Load(...); var themeName = doc.Root.Element("themename").Value; Guid themeGuid = Guid.NewGuid(); foreach (var element in... more 7/28/2014 10:11:50 AM
Every enum has an automatically generated static valueOf method which parses a string. So you can use: String colorName = input.readLine(); Color color = Color.valueOf(colorName); However, this will throw an exception if the given name... more 7/28/2014 9:45:55 AM
The problem isn't the fact that you're setting the property - it's that you're trying to use the result of setting the property as the input for setting banner itself. You just want: banner.Disabled = false; more 7/28/2014 8:43:26 AM