Hi, Today I needed a simple code that returns the business days between two dates and ended with this: public static int GetFullWorkingDaysBetween(DateTime firstDate, DateTime lastDate, IEnumerable holidays) { if (firstDate > lastDate)// Swap the dates if firstDate > lastDate { DateTime tempDate = firstDate; firstDate = lastDate; lastDate = tempDate; } int days = (int)(lastDate.Subtract(firstDate).Ticks / TimeSpan.TicksPerDay); int weekReminder = days % 7; if (weekReminder > 0) { switch (firstDate.DayOfWeek) { case DayOfWeek.Monday: days = days - ((weekReminder > 5) ? 1 : 0); // Another way for this: //days = days - ((int)weekReminder % 5); // but i think its more expensive ...
To use fastJson Serializer with WCF Web Service: Within a Web Site or App Project (VS), Add AjaxService Add: Method: Get, Use: Only to retrieve Data [ OperationContract ] [ WebGet (ResponseFormat = WebMessageFormat .Json)] public Stream TestStream( string ticker) { WebOperationContext .Current.OutgoingResponse.ContentType = "application/json" ; string jsonString= "{\"d\":{}}" ;//Here you do the serialization MemoryStream ms = new MemoryStream ( ASCIIEncoding .Default.GetBytes(jsonString)); return ms; } Method: Post, Use: Insert data / data manipulation [ OperationContract ] [ WebInvoke (Method= "POST" , ResponseFormat = WebMessageFormat .Json)] public Stream TestStream( string ticker) { WebOperationContext .Current.OutgoingResponse.ContentType = "application/json" ; string jsonString= "{\"d\":{}}" ;//Here you do the serialization MemoryStream ms = new MemoryStream ( ASCIIEncoding .Def...