Consider this code (prestuffed with an example):
DateTime dt1 = DateTime.Parse("7/30/2010 9:33:29.1234567 AM");
DateTime dt2 = DateTime.Parse("6/30/2010 9:33:00.7654321 AM");
TimeSpan ts = dt1 - dt2;
Console.WriteLine(string.Format( "{0:d.hh:mm:ss.ff}", ts ));
This is representative of a piece of code that I've had working since .NE...
I have a large set (100+ million) of observations with the date represented as a custom string format. We did not generate the date strings, I just need to convert the date string to a datetime type.
How do I convert a string date (eg, 12 JUN 2010) to a datetime? My thoughts are to parse the string into components, assemble them in the...
I brute-forced summing of all primes under 2000000. After that, just for fun I tried to parallel my for, but I was a little bit surprised when I saw that Parallel.For gives me an incorrect sum!
Here's my code : (C#)
static class Problem
{
public static long Solution()
{
long sum = 0;
//Correct result is 14291382...
When working with files in C#, I am conditioned to think about freeing the associated resources. Usually this is a using statement, unless its a one liner convenience method
like File.ReadAllLines, which will open and close the file for me.
.Net 4.0 has introduced the convenience method File.ReadLines. This returns an IEnumerable and ...
HtmlString vs. MvcHtmlString
What are the differences bettween those two, or when to prefer one over the other?
Edit:
One thing to prefer MvcHtmlString over HtmlString is the extension method IsNullOrEmpty of MvcHtmlString.
...
For a simple application that use asp.net mvc 3 and .net-4, what service locator application is preferred, with performance concern in mind?
...
I have three dropdowns, which are bound to the same EntityDataSource control. This results in three identical queries of my database for the data. I have looked for some way to enable caching on the EntityDataSource control, but it doesn't seem to be there? Am I missing something? Am I going to have to roll my own databinding instead...
My requirements:
I need to store a collection of objects inside a class,
objects must be accessible by their key (which will be unique string), search/remove/replace must work like this
MyClass somethingNew = new MyClass();
// set someproperties on somethingNew
somethingNew.Id = "FooBar";
// theOtherObject already contains an ...
Pretty much all of the tutorials/introductions to Windows Workflow Foundation seem to be targeted at versions prior to 4.0, or are somewhat simplistic and don't really show me anything about WHAT the real strengths of Workflows are.
Could someone point me in the direction of some slightly meatier tutorials (clearly my google-fu is faili...
We've already established previously that DCS serializes/deserializes objects alphabetically. However, after further investigation I've discoverred this is not entirely true.
If we have a structure like this:
[DataContract]
public class Content
{
[DataMember]
public string Title;
[DataMember]
public string Slug;
[D...
So I've been tinkering in the last few days with nServiceBus.
Here a few things that I want to know.
How do I get a version that will play nice with .net 4.0? I'm using NServiceBus.2.0.0.1145 which I believe is the lastest but I needed to convert the sample solutions to VS2010 (which works fine) but their target framework is 3.5. Also...
Hi,
I am using dynamic data entities linq to sql project. For my test project I have one table, with 10 columns and a single primary key for example. Almost all the columns are varchars.
I can get the basic project up and running fine - update, delete, insert etc.
Since it has no foreign keys, there are no search filters rendered. I w...
I just starting to use Visual Studio 2010 and .NET 4.0. I created a new WPF project a DLL built for .NET 2.0. When I build the project, I get a bunch of warnings like this one:
The referenced assembly
"MicroFour StrataFrame Business...processorArchitecture=MSIL"
could not be resolved because it has a dependency on
"System.Web, Version...
I have an net assembly that was originally written in framework 1.1.
I have complied this with a framework 4.0 and need to put in the GAC
There is no Framework configuration tool (Administrative Tools/Microsoft .Net Framework n.n Configuration any longer.
How do I view/Manage Framewok 4.0 GAC assemblies.
I am using this assembly with S...
I am working on an app that is using Synchronization Framework v2. I am basically done with it, but would like to offer some better fedback about the progress of the synchronization. I was looking at one of the Synchframework examples that Microsoft offers, SharingAppDemo-CEProviderEndToEnd, and see that the have a method in the Progress...
I'm looking at a project that has been developed and maintained with Entity Framework 1 that is relatively stable at this point. I'm wondering if people have ever migrated a project like that to EF 4 and if anyone can share any particular difficulties they may have had. I know there are a lot of benefits to look forward to but I'm tryi...
Hi,
I am running .net 4.0 asp.net app on IIS 7. I want to know if there is an easy way of adding rows to an excel 2007/2010 (not too fussed) template file that a user can download from the server.
For example, the user might check a couple of tick boxes and clicks a button on the web page. The server does a sql query on a table and com...
I have an application in .NET 4 that uses MEF for extensibility. My main application has three assemblies: Host, Application and Contracts.
Host is the "boot-strapping" executable that creates the container and does the composition.
Application contains the logic of my application, and more extension points for 3rd parties.
Contracts...
I am looking at using design by contract for a personal project in C# using .NET 4.
I have been reading about Microsoft's attempt at a design by contract framework:
http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx
But there are many alternatives and I'm baffled - so which is the best and why? What are the pros and cons of each?
...
In ASP.NET 4, we can use the new <%: ... %> operator to output HTML encoded strings. Is it possible to configure ASP.NET 4 (in web.config) so that the <%= ... %> operator will also HTML encode strings?
...