3

私はC言語で2つの構造体を持っています:

struct CSquare
{
    char Side;
    int  Row;
    int  Col;    
};

struct CSide
{
   char     m_Side;           
   char     m_Blocks[3][3];     
   CSquare  *m_Moves;
};

および C++ コード:

int Count = 0;
int Flag = 0;
if (m_Down->m_Blocks[0][1] == *m_Down)
{
    Count++;
    Flag |= 2;
    // type of m_Down is CSide
}

それらをC#に変換しようとしています:

public class Square
{
    public char Side { get; set; }
    public int Row { get; set; }   
    public int Col { get; set; }
}

public class CubeSide
{
    private char Side { get; set; }
    private char[,] _block = new char[3, 3];
    private Square[] moves;

    public char[,] Block
    {
        get { return _block; }
        set { _block = value; }
    }

    internal Square[] Moves
    {
        get { return moves; }
        set { moves = value; }
    }
}

しかし、行を変換する方法がわかりません:

if (m_Down->m_Blocks[0][1] == *m_Down)

C#に?

この行を C# に変換するにはどうすればよいですか?

4

1 に答える 1

1

this line make no sense, i guess it's always evaluate to false.

What you can do is to set a breakpoint on that line and perform a quick watch, evaluate *m_Down to make sure there's no overload operator.

Then, evaluate the condition. Depending on your type of project, put some printf("inside the if")/printf("inside the else"), messagebox or write it in a file. If the condition is evaluate to true, print the value of m_Down->m_BLocks[0][1] and *m_Down...

Make sure you first understand the logic behind this line. Once you understand it, it will be easy to write it in c#

PS: in C#, use Byte instead of Char

于 2013-05-25T21:26:19.773 に答える