> Single quotes vs. double quotes in C or C++12个
我正在翻译一些C到C#代码,我看到下面的定义:
#define x 'liaM'
首先,这个单引号是什么意思?我在c#中使其成为字符串常量吗?
其次,这个常数被赋值为C中的uint变量.这是如何工作的?
uint m = x;
#define x 'liaM'
首先,这个单引号是什么意思?我在c#中使其成为字符串常量吗?
其次,这个常数被赋值为C中的uint变量.这是如何工作的?
uint m = x;
public static int ChunkIdentifierToInt32(string s) { if (s.Length != 4) throw new ArgumentException("Must be a four character string"); var bytes = Encoding.UTF8.GetBytes(s); if (bytes.Length != 4) throw new ArgumentException("Must encode to exactly four bytes"); return BitConverter.ToInt32(bytes,0); }