输入千分位格式数字 string.Format("数字格式 {0:n2},", 123456789)
这个主要和 IFomatProvider 接口有关,NumberFormatInfo numberFomatProvider = new NumberFormatInfo();
C# 中各种流的操作【参考别人博客】
https://www.cnblogs.com/JimmyZheng/archive/2012/03/17/2402814.html
定时执行
public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //设置30秒处理一次 System.Timers.Timer myTimer = new System.Timers.Timer(1000*30);//修改时间间隔 myTimer.Elapsed += new System.Timers.ElapsedEventHandler(AutoExec); myTimer.AutoReset = true; myTimer.Enabled = true; } private void AutoExec(object sender, System.Timers.ElapsedEventArgs e) { //插入访问日志记录 Logtxt log = new Logtxt(AppDomain.CurrentDomain.BaseDirectory + @"/log/APILog/Log.txt"); log.log("**NowTime**:"+Guid.NewGuid().ToString()); } }
发送邮件
//from email,to email,主题,邮件内容 MailMessage mailmessage = new MailMessage("test@centos.com", "886688668@qq.com", "this is a test", "yes!test!"); mailmessage.Priority = MailPriority.Normal; //邮件优先级 SmtpClient smtpClient = new SmtpClient("mail.centos.com", 25); //smtp地址以及端口号 smtpClient.Credentials = new NetworkCredential("test@centos.com", "*******");//smtp用户名密码 smtpClient.EnableSsl = false; //启用ssl smtpClient.Send(mailmessage); //发送邮件 return Content("发送成功");
Unix时间戳
DateTimeOffset BaseTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); long unixTime = (long)(DateTime.Now.ToUniversalTime() - BaseTime).TotalSeconds; long unixTime3 = (long)(DateTime.Now - BaseTime).TotalSeconds; DateTime dt = DateTimeOffset.FromUnixTimeSeconds(unixTime).DateTime; return Content("unixTime:" + unixTime.ToString()+ "--unixTime2:"+ unixTime3.ToString()+"*DateTime:"+ dt.ToString("yyyy-MM-dd HH:mm"));