Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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++;
    }
}
Posted
Updated 26-Aug-14 4:59am
v3
Comments
[no name] 26-Aug-14 10:55am    
C != .NET && C != C#. It not called a "conversion" it's called a rewrite.
elmutasim23 26-Aug-14 10:58am    
this code is been written in reactos and i don't know what this code mean

The function converted should like this,maybe
C#
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();
        }
    }
}


I think just use "String.ToLower()" instead of the "partstrlwr",since no difference here beween this two in C#.
 
Share this answer
 
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) The c character is not an equals sign.

The code in the loop itself looks like garbage.
Convert c to lower case, so 'A' becomes 'a' and so forth. But since c 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...
 
Share this answer
 
Comments
elmutasim23 26-Aug-14 16:27pm    
i don't know what this code for but this code is in alias file in reactos cmd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900