Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
Questionimage to text converter program Pin
arvindnitin711-Nov-14 5:56
arvindnitin711-Nov-14 5:56 
AnswerRe: image to text converter program Pin
Ravi Bhavnani11-Nov-14 5:59
professionalRavi Bhavnani11-Nov-14 5:59 
AnswerRe: image to text converter program Pin
Pete O'Hanlon11-Nov-14 5:59
mvePete O'Hanlon11-Nov-14 5:59 
Questionimage to text converter program Pin
arvindnitin711-Nov-14 5:54
arvindnitin711-Nov-14 5:54 
AnswerRe: image to text converter program Pin
Eddy Vluggen11-Nov-14 5:57
professionalEddy Vluggen11-Nov-14 5:57 
QuestionDate Diffrence Month Wise Pin
heyvid11-Nov-14 0:54
heyvid11-Nov-14 0:54 
AnswerRe: Date Diffrence Month Wise Pin
OriginalGriff11-Nov-14 1:19
mveOriginalGriff11-Nov-14 1:19 
AnswerRe: Date Diffrence Month Wise Pin
BillWoodruff11-Nov-14 4:54
professionalBillWoodruff11-Nov-14 4:54 
Assuming you want ... given two dates ... to generate a data structure that contains each Month from the starting date to the ending date, and, for each month, the number of days in the month:
C#
// required
using System.Globalization;

private DateTimeFormatInfo dtf = new DateTimeFormatInfo();

// DateTime 1, DateTime 2 => Dictionary<string, int>
// assumes DateTime 2 is later than DateTime 1
// for the first month: days are calculated as the number of days in the month minus current day
// for the last month: days are taken from the current day in the last month

private Dictionary<string, int> getMonthDays(DateTime d1, DateTime d2)
{
    int nMonths = ((d2.Year - d1.Year) * 12) + d2.Month - d1.Month - 1;

    var dctMonthDays = new Dictionary<string, int>();

    for (int i = 0; i <= nMonths; i++)
    {
        int daysInMonth = DateTime.DaysInMonth(d1.Year, d1.Month);
        string monthName = dtf.GetMonthName(d1.Month);

        if (i == 0)
        {
            dctMonthDays.Add(monthName, daysInMonth - d1.Day);
        }
        else if (i == nMonths)
        {
            dctMonthDays.Add(monthName, d2.Day);
        }
        else
        {
            dctMonthDays.Add(monthName, daysInMonth);
        }

        d1 = d1.AddMonths(1);
    }

    return dctMonthDays;
}

// test in a method or EventHandler
DateTime d1 = DateTime.Now;

DateTime d2 = d1.AddMonths(7);

var monthDayDiff = getMonthDays(d1, d2);

foreach (var kvp in monthDayDiff)
{
    Console.WriteLine("Month: {0} Days: {1}", kvp.Key, kvp.Value);
}

// result of test in Console Window on Nov. 11, 2014
// Month: November Days: 19
// Month: December Days: 31
// Month: January Days: 31
// Month: February Days: 28
// Month: March Days: 31
// Month: April Days: 30
// Month: May Days: 11

« I am putting myself to the fullest possible use which is all, I think, that any conscious entity can ever hope to do » HAL (Heuristically programmed ALgorithmic computer) in "2001, A Space Odyssey"

QuestionHow do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
Member 1094850810-Nov-14 21:37
Member 1094850810-Nov-14 21:37 
AnswerRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
BillWoodruff10-Nov-14 21:57
professionalBillWoodruff10-Nov-14 21:57 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
Member 1094850810-Nov-14 22:17
Member 1094850810-Nov-14 22:17 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
OriginalGriff10-Nov-14 22:20
mveOriginalGriff10-Nov-14 22:20 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
BillWoodruff11-Nov-14 5:13
professionalBillWoodruff11-Nov-14 5:13 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
OriginalGriff11-Nov-14 5:35
mveOriginalGriff11-Nov-14 5:35 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
Pete O'Hanlon10-Nov-14 22:48
mvePete O'Hanlon10-Nov-14 22:48 
GeneralRe: How do I apply Farseer Physics Engine Collision on my image? I tried it on my codes and it is not working. I am using Farseer 2.1 Pin
OriginalGriff10-Nov-14 22:18
mveOriginalGriff10-Nov-14 22:18 
QuestionException Regarding RCW (Runtime Callable Wrapper) Pin
Django_Untaken10-Nov-14 7:37
Django_Untaken10-Nov-14 7:37 
AnswerRe: Exception Regarding RCW (Runtime Callable Wrapper) Pin
Richard MacCutchan10-Nov-14 21:34
mveRichard MacCutchan10-Nov-14 21:34 
AnswerRe: Exception Regarding RCW (Runtime Callable Wrapper) Pin
Bernhard Hiller10-Nov-14 23:28
Bernhard Hiller10-Nov-14 23:28 
Questionquestion re abstract class with no implementation allowing an abstract property to be set in the 'cTor Pin
BillWoodruff10-Nov-14 6:25
professionalBillWoodruff10-Nov-14 6:25 
AnswerRe: question re abstract class with no implementation allowing an abstract property to be set in the 'cTor Pin
Richard MacCutchan10-Nov-14 7:08
mveRichard MacCutchan10-Nov-14 7:08 
SuggestionRe: question re abstract class with no implementation allowing an abstract property to be set in the 'cTor Pin
Richard Deeming10-Nov-14 8:08
mveRichard Deeming10-Nov-14 8:08 
GeneralRe: question re abstract class with no implementation allowing an abstract property to be set in the 'cTor Pin
Sergey Alexandrovich Kryukov10-Nov-14 10:05
mvaSergey Alexandrovich Kryukov10-Nov-14 10:05 
GeneralRe: question re abstract class with no implementation allowing an abstract property to be set in the 'cTor Pin
Richard Deeming10-Nov-14 10:13
mveRichard Deeming10-Nov-14 10:13 
GeneralSure Pin
Sergey Alexandrovich Kryukov10-Nov-14 10:17
mvaSergey Alexandrovich Kryukov10-Nov-14 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.