Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将python行移植到c#代码_C#_Python - Fatal编程技术网

将python行移植到c#代码

将python行移植到c#代码,c#,python,C#,Python,我正在将简短的python代码移植到c# 但我停在这条线上,我不知道这是什么意思 array.append( ("%x" % value)[-1] ) 有人吗?thx此:%x”%value提供一个字符串,其中包含以十六进制表示的值 [-1]为您提供上述内容的最后一个字符 array.append将该字符添加到array的末尾(可能是一个列表) 您可以通过使用Python REPL来解决这个问题: >>> "%x" % 142 '8e' >>> ("%x" %

我正在将简短的python代码移植到c# 但我停在这条线上,我不知道这是什么意思

array.append( ("%x" % value)[-1] )
有人吗?thx

此:
%x”%value
提供一个字符串,其中包含以十六进制表示的

[-1]
为您提供上述内容的最后一个字符

array.append
将该字符添加到
array
的末尾(可能是一个列表)

您可以通过使用Python REPL来解决这个问题:

>>> "%x" % 142
'8e'
>>> ("%x" % 142)[-1]
'e'
>>> array = []
>>> array.append(("%x" % 142)[-1])
>>> array
['e']

这和做这件事是一样的:

array.append(str(hex(value))[-1])
将整数(任意大小)转换为前缀为“0x”的小写十六进制字符串

[-1]
提供字符串的最后一个字符