代码如下:/// /// 计算本周起始日期(礼拜一的日期) /// /// 该周中任意一天 /// 返回礼拜一日期,后面的具体时、分、秒和传入值相等 public static DateTime CalculateFirstDateOfWeek(DateTime someDate) { int i = someDate.DayOfWeek – DayOfWeek.Monday; if (i == -1) i = 6;// i值 > =
Math.abs()的实现源码
通过三目运算符判断a是否小于0来实现
/**
* Returns the absolute value of an {code int} value.
* If the argument is not negative, the argument is returned.
* If the argument is negative, the negation of the argument is returned.
*
* Note that
C#端
using System;
using System.IO;
using System.Security.Cryptography;
namespace 计算文件的MD5值
{
class MD5_Helper
{
///
/// 文件MD5校验
///
/// 文件绝对路径
/// MD5校验码
public string getMD5Hash(string pathName)
最大公约数:指两个或多个整数共有约束中最大的一个。
最小公倍数:如果有一个自然数a能被自然数b整除,则称a为b的倍数,b为a的约数,对于两个整数来说,指该两数共有倍数中最小的一个。
代码如下:/// /// 最大公约数/// /// /// /// public static int GCD(int a, int b){int gcd = 1;int min = a > b ? b : a;for (int i = min