Guid.NewGuid().ToString()的几种格式

1、Guid.NewGuid().ToString("N") 结果为:
      38bddf48f43c48588e0d78761eaa1ce6

2、Guid.NewGuid().ToString("D") 结果为:
      57d99d89-caab-482a-a0e9-a0a803eed3ba

3、Guid.NewGuid().ToString("B") 结果为:
     {09f140d5-af72-44ba-a763-c861304b46f8}

4、Guid.NewGuid().ToString("P") 结果为:
     (778406c2-efff-4262-ab03-70a77d09c2b5)

转载于:https://www.cnblogs.com/vinsonLu/p/4174343.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以对这段代码进行如下的优化: ``` if (theData.Id.IsNullOrEmpty()) { theData.Id = Guid.NewGuid().ToSequentialGuid(); if (theData.ifNeedVerifyCode == true && SessionHelper.Session["verifyCode"].IsNullOrEmpty()) { return Error("请先发送验证码"); } if (theData.ifNeedVerifyCode == true && SessionHelper.Session["verifyCode"].ToString() != theData.verifyCode) { return Error("验证码不正确"); } var unweightedCount = _wTapplicationBusiness.GetIQueryable() .Where(a => a.Carno == theData.Carno && a.ExpectedDate == theData.ExpectedDate && a.WeightTime.IsNullOrEmpty()) .Count(); if (unweightedCount > 0) { return Error("该车在该送货日期存在未过磅的信息,请过磅后再新增数据"); } _wTapplicationBusiness.AddData(theData); _wTapplicationBusiness.GetLogger().WriteOperateLog("WTapplication信息添加", "id:" + theData.Id, true); } else { var unweightedCount = _wTapplicationBusiness.GetIQueryable() .Where(a => a.Carno == theData.Carno && a.ExpectedDate == theData.ExpectedDate && a.WeightTime.IsNullOrEmpty() && a.Id != theData.Id) .Count(); if (unweightedCount > 0) { return Error("该车在该送货日期存在未过磅的信息,请过磅后再新增数据"); } _wTapplicationBusiness.UpdateData(theData); _wTapplicationBusiness.GetLogger().WriteOperateLog("WTapplication信息修改", "id:" + theData.Id, true); } ``` 主要的优化点如下: 1. 合并了两个 `if` 语句,使得代码更加简洁。 2. 重命名了 `UnWightCount` 变量为 `unweightedCount`,符合命名规范。 3. 将 `_wTapplicationBusiness.GetIQueryable()` 的查询条件提取出来,避免重复写代码。 4. 将新增和修改的代码分别写在了两个分支中,使得代码更加清晰易懂。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值