在XML文档中引用C#关键字,可以使用特殊的转义字符来表示这些关键字。以下是一些常见的C#关键字及其对应的转义字符:
abstract
:&abstract;
as
:&as;
base
:&base;
bool
:&bool;
break
:&break;
byte
:&byte;
case
:&case;
catch
:&catch;
char
:&char;
checked
:&checked;
class
:&class;
const
:&const;
continue
:&continue;
decimal
:&decimal;
default
:&default;
delegate
:&delegate;
do
:&do;
double
:&double;
else
:&else;
enum
:&enum;
event
:&event;
explicit
:&explicit;
extern
:&extern;
false
:&false;
finally
:&finally;
fixed
:&fixed;
float
:&float;
for
:&for;
foreach
:&foreach;
goto
:&goto;
if
:&if;
implicit
:&implicit;
in
:∈
int
:∫
interface
:&interface;
internal
:&internal;
is
:&is;
lock
:&lock;
long
:&long;
namespace
:&namespace;
new
:&new;
null
:&null;
object
:&object;
operator
:&operator;
out
:&out;
override
:&override;
params
:¶ms;
private
:&private;
protected
:&protected;
public
:&public;
readonly
:&readonly;
ref
:&ref;
return
:&return;
sbyte
:&sbyte;
sealed
:&sealed;
short
:&short;
sizeof
:&sizeof;
stackalloc
:&stackalloc;
static
:&static;
string
:&string;
struct
:&struct;
switch
:&switch;
this
:&this;
throw
:&throw;
true
:&true;
try
:&try;
typeof
:&typeof;
uint
:&uint;
ulong
:&ulong;
unchecked
:&unchecked;
unsafe
:&unsafe;
ushort
:&ushort;
using
:&using;
virtual
:&virtual;
void
:&void;
volatile
:&volatile;
while
:&while;
例如,如果你想在XML文档中使用class
关键字,可以将其替换为&class;
。这样,XML解析器就会将其视为普通文本,而不是作为一个标签来解析。
领取专属 10元无门槛券
手把手带您无忧上云