来自于reactos的C#的C代码 [英] C code to C# from reactos
本文介绍了来自于reactos的C#的C代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经用C语言将源代码转换为C#,但是有很多错误,我需要帮助:
I've converted a source code in C language to C# but there is a lot of errors, I need a help:
internal static VOID partstrlwr(string str)
{
string c = str;
while ( c && !_istspace ( c) && c != _T('='))
{
c = _totlower ( c);
c++;
}
}
推荐答案
转换的函数应该是这样的,也许是
The function converted should like this,maybe
internal static void partstrlwr(ref string str)
{
CharEnumerator c = str.GetEnumerator();
str = string.Empty;
while (c.MoveNext())
{
if (!c.Current.Equals(' ') && !c.Current.Equals('='))
{
str += c.Current.ToString().ToLower();
}
else
{
str += c.Current.ToString();
}
}
}
我认为只需使用String.ToLower()代替partstrlwr,因为这两者在C#中没有区别。
I think just use "String.ToLower()" instead of the "partstrlwr",since no difference here beween this two in C#.
循环只检查三个条件都是真的:
1)c
不是null(C语言使用空终止字符串; C#不; t)
2)无论_istspace函数做什么,倒置。因此,如果参数是空格,则返回true,那么循环不需要空格。
3)c
字符是不是等号。
循环中的代码看起来像垃圾。
转换c
小写,所以'A'变为'a'等等。但是因为c
是一个字符串,所以它的作用是任何人猜测
增加字符串 - 我不知道它会做什么...因为你从来没有用它作为指针...
你知道的地方(以及为什么)我不知道。
但就个人而言,我会把它放回去,假装我从未见过它......
The loop just checks the three conditions are all true:
1)c
is not a null (the C language uses null terminated strings; C# doesn;t)
2) Whatever the _istspace function does, inverted. So if it returns "true" if the parameter is a space, then the loop wants it not a space.
3) Thec
character is not an equals sign.
The code in the loop itself looks like garbage.
Convertc
to lower case, so 'A' becomes 'a' and so forth. But sincec
is a string, quite what it does to that is anybodies guess
Increment the string - and I have no idea what that will do...since you never use this as a pointer...
Quite where you got that (and why) I don't know.
But personally, I'd put it back and walk away pretending I'd never seen it...
这篇关于来自于reactos的C#的C代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文