当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net System.Guid ToString五种格式

asp.net System.Guid ToString五种格式

2017年12月08日  | 移动技术网IT编程  | 我要评论

黑镜第四季 下载,601299资金流向,信用卡刷卡套现

参考:

image

测试代码:

using system;
using system.collections.generic;
using system.linq;
using system.text;

namespace guidtostring
{
  class program
  {
    static void main(string[] args)
    {
      console.writeline(" -->" + system.guid.newguid().tostring());
      console.writeline("n-->" + system.guid.newguid().tostring("n"));
      console.writeline("d-->" + system.guid.newguid().tostring("d"));
      console.writeline("b-->" + system.guid.newguid().tostring("b"));
      console.writeline("p-->" + system.guid.newguid().tostring("p"));
      console.writeline("x-->" + system.guid.newguid().tostring("x"));
      console.readkey();
    }
  }
}

测试结果:

image

注意事项:只能使用n、d、b、p、x(不区分大小写)空,使用其他字母会出现异常

image

格式字符串只能是“d”、“d”、“n”、“n”、“p”、“p”、“b”、“b”、“x”或“x”。

异常情况:

image

以下都正常:

using system;
using system.collections.generic;
using system.linq;
using system.text;

namespace guidtostring
{
  class program
  {
    static void main(string[] args)
    {
      console.writeline(" -->" + system.guid.newguid().tostring());
      console.writeline(" -->" + system.guid.newguid().tostring(""));
      console.writeline("n-->" + system.guid.newguid().tostring("n"));
      console.writeline("n-->" + system.guid.newguid().tostring("n"));
      console.writeline("d-->" + system.guid.newguid().tostring("d"));
      console.writeline("d-->" + system.guid.newguid().tostring("d"));
      console.writeline("b-->" + system.guid.newguid().tostring("b"));
      console.writeline("b-->" + system.guid.newguid().tostring("b"));
      console.writeline("p-->" + system.guid.newguid().tostring("p"));
      console.writeline("p-->" + system.guid.newguid().tostring("p"));
      console.writeline("x-->" + system.guid.newguid().tostring("x"));
      console.writeline("x-->" + system.guid.newguid().tostring("x"));
      console.readkey();
    }
  }
}

image

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)

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网