Guid.ToString(”B”).ToUpper() means???

by Andrew 2. February 2009 11:44

When you want print out GUID like this format
{855F9A70-9A43-435B-A5B1-B91A7F58BAD1} => bracket surrounded….
you can use that one.

For example, Guids of SPlist or SPField  
guid.ToString(”B”).ToUpper();

[Sample Code here]:

1:
2:
3: string strGuid = "0b51264d-baa6-49dc-8970-1d24979053ac";
4: Guid guid = new Guid(strGuid);
5: string guidBTest1 = guid.ToString();
6: string guidBTest2 = guid.ToString("B").ToUpper();
7: Response.Write(guidBTest1 + "");
8: Response.Write(guidBTest2);
9:

[In Detail]
The format parameter can contain the following format specifiers. In the table that follows, all digits in the return value are hexadecimal. Each character ‘x’ represents a hexadecimal digit; each hyphen (’-'), bracket (’{', ‘}’), and parenthesis (’(', ‘)’) appears as shown.

SpecifierFormat of Return Value
N 32 digits:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
D 32 digits separated by hyphens:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
B 32 digits separated by hyphens, enclosed in brackets:
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
P 32 digits separated by hyphens, enclosed in parentheses:
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

The provider parameter is reserved for future use and does not contribute to the execution of this method. A null reference can be coded for this parameter.

- Reference from http://msdn.microsoft.com/en-us/library/s6tk2z69.aspx

Tags:

NetFramework