Difference in months between two dates

前端 未结 30 1204
天命终不由人
天命终不由人 2020-11-22 11:02

How to calculate the difference in months between two dates in C#?

Is there is equivalent of VB\'s DateDiff() method in C#. I need to find difference in

30条回答
  •  无人及你
    2020-11-22 11:57

    I checked the usage of this method in VB.NET via MSDN and it seems that it has a lot of usages. There is no such a built-in method in C#. (Even it's not a good idea) you can call VB's in C#.

    1. Add Microsoft.VisualBasic.dll to your project as a reference
    2. use Microsoft.VisualBasic.DateAndTime.DateDiff in your code

提交回复
热议问题