i have 2 classes. one is a partial class belonging to winform, and the other is a code class of chess.
problem , is that my enums arent being triggered , or they reset themselves..

okay, so in the code class i have got this:

class PiecePromotion
{
    PromotionPieces pieceP;   


    public Pieces[,] promotionPresentation(Pieces[,] pieces, bool black, bool white, int rowEnd, int columnEnd)
    {

  

        pieceP = chess.PromotedPiece ;// this property should be retrieved after i click on the radio box. pieceP should be assigned to be an enum of ROOK, QUEEN, KNIGHT, BISHOP.
   
        if (black)
        {
            switch (pieceP)
            {           
                case PromotionPieces.ROOK:
                    pieces[rowEnd, columnEnd] = new Rook("BR3");
                    break;
                case PromotionPieces.BISHOP:
                    pieces[rowEnd, columnEnd] = new Knight("BN3"); 
                    break;
                case PromotionPieces.KNIGHT:
                    pieces[rowEnd, columnEnd] = new Bishop("BB3");
                    break;
                case PromotionPieces.QUEEN:
                    pieces[rowEnd, columnEnd] = new Queen("BQueen2");
                    break;
                default:
                    ChessBoard.moveValidity = "Invalid Choice";
                    break;
            }                   
        }

        if (white)
        {
             switch (pieceP)
            {
                case PromotionPieces.ROOK:
                    pieces[rowEnd, columnEnd] = new Rook("WR3");
                    break;
                case PromotionPieces.BISHOP:
                    pieces[rowEnd, columnEnd] = new Knight("WN3"); 
                    break;
                case PromotionPieces.KNIGHT:
                    pieces[rowEnd, columnEnd] = new Bishop("WB3"); 
                    break;
                case PromotionPieces.QUEEN:
                    pieces[rowEnd, columnEnd] = new Queen("WQueen2"); 
                    break;
                default:
                    ChessBoard.moveValidity = "Invalid Choice"; break;// all i get an invalid choice, as if pieceP wasnt assigned. why is that?
            }       
        }
        return pieces;
    }

}

and in the winform class i have got his:

public STATE Gamestate { set; get; }
        public PromotionPieces PromotedPiece { set; get; }// when i click on the radiobox this property should be assigned

        public void update()
        {
            move1.Text = moveValidity;
            PromotionTable.Visible = true;// in this table there are radioboxes. each radiobox triggers an event that assigned PromotedPiece....

       
        }

 


        private void radioButtonQueen_CheckedChanged(object sender, EventArgs e)
        {
            PromotedPiece = PromotionPieces.QUEEN; 
        }

        private void radioButtonRook_CheckedChanged(object sender, EventArgs e)
        {
            PromotedPiece = PromotionPieces.ROOK;
        }

        private void radioButtonBishop_CheckedChanged(object sender, EventArgs e)
        {
            PromotedPiece = PromotionPieces.BISHOP;
        }

        private void radioButtonKnight_CheckedChanged(object sender, EventArgs e)
        {
            PromotedPiece = PromotionPieces.KNIGHT;
        }
  
    }

damn, i forgot to include those:

chess is the instance object of ChessBoard (the partial class).

PromotionPieces{ROOK, QUEEN, BISHOP, KNIGHT},

Basically i corrected the error, by making
public PromotionPieces PromotedPiece { set; get; } ,,static.

previously if i had an enum in the class, then when i would refer to it in the partial class, it would not retain its value, and vice versa.

if i change the property from static, the switch in either of the files wouldnt work, they would get some 0 or default value.

i was stuck on that problem for 2 hours, till i couldnt take it anymore.

i wish i knew why when you send an enum from a class to a partial class and vice versa, it nullifies itself(or doesnt get value).

i wish i knew why when you send an enum from a class to a partial class and vice versa, it nullifies itself(or doesnt get value).

It doesn't, enums aren't nullifable. It was something in your code :)

so why when i put it static, it worked :(...

but if you say that, there are no accessability restrictions or something similar, than i believe you

This article has been dead for over six months. Start a new discussion instead.