Click here to Skip to main content
15,905,229 members
Home / Discussions / C#
   

C#

 
AnswerRe: E-Mails Moderator. Pin
Dave Kreskowiak27-Oct-05 14:26
mveDave Kreskowiak27-Oct-05 14:26 
AnswerRe: E-Mails Moderator. Pin
Christian Graus27-Oct-05 15:04
protectorChristian Graus27-Oct-05 15:04 
AnswerRe: E-Mails Moderator. Pin
Michael Hendrickx28-Oct-05 0:10
Michael Hendrickx28-Oct-05 0:10 
QuestionE-Mails Moderator. Pin
Asare27-Oct-05 8:03
Asare27-Oct-05 8:03 
QuestionHow to create Plug-in for an application Pin
Anindya Chatterjee27-Oct-05 7:00
Anindya Chatterjee27-Oct-05 7:00 
AnswerRe: How to create Plug-in for an application Pin
Gary Thom27-Oct-05 7:16
Gary Thom27-Oct-05 7:16 
QuestionEnums and Ints Pin
budidharma27-Oct-05 6:41
budidharma27-Oct-05 6:41 
AnswerRe: Enums and Ints Pin
whizzs27-Oct-05 8:56
whizzs27-Oct-05 8:56 
Whew, where to begin. First about the enums. I am assuming your Card class set method is structured as such: Card.Set ( Rank r, Suit s) and you have an array of Cards in deck[]. So to set your first card you would say deck[0].Set ( Rank.Hearts, Suit.Ace ).

Now the first problem is you have Rank and Suit mixed up, the Suit should be hearts, clubs, etc. Confusing to read.

Your second issue is your Card property Rank and Suit have the same name as your enum, that cannot be. I see what you are doing, you want to return that enum to set the next card with it, but you can't have the same name. I would change the name to CardRank and CardSuit and define the property like this:

//member variables
private Rank cardRank;
private Suit cardSuit;

//Properties
public Rank CardRank
{
set
{
cardRank = value;
}
get
{
return cardRank;
}
}
// do the same for CardSuit

now your swap functions will be:
tempCard.Set ( deck[first].CardRank, deck[first].CardSuit );

If you used integers in you Set function prototype then this won't work and you have to modify your properties to convert to integer or from integer depending on what your members are.

Your third issue is your last card will never get shuffled, Random returns a number less than the number passed in and your first and second could theoretcially be the same card (not a real problem, just wasted a shuffle)

If you want the integer value of an enum do this:
int x = (int) Rank.Clubs; //now x = 4
or
Rank r = Rank.Clubs;
int x = (int) r; //x = 4

finally if you want the string value:
string s = Rank.Clubs.ToString(); // s = "Clubs"
GeneralRe: Enums and Ints Pin
budidharma27-Oct-05 9:12
budidharma27-Oct-05 9:12 
GeneralRe: Enums and Ints Pin
budidharma27-Oct-05 9:28
budidharma27-Oct-05 9:28 
GeneralRe: Enums and Ints Pin
[Marc]27-Oct-05 12:29
[Marc]27-Oct-05 12:29 
GeneralRe: Enums and Ints Pin
whizzs28-Oct-05 3:38
whizzs28-Oct-05 3:38 
QuestionWindowses in C# Pin
Stanciu Vlad27-Oct-05 6:30
Stanciu Vlad27-Oct-05 6:30 
AnswerRe: Windowses in C# Pin
enjoycrack27-Oct-05 10:22
enjoycrack27-Oct-05 10:22 
AnswerRe: Windowses in C# Pin
Stanciu Vlad27-Oct-05 21:39
Stanciu Vlad27-Oct-05 21:39 
Questionproblem aborting a thread on shutdown Pin
Dan Neely27-Oct-05 6:01
Dan Neely27-Oct-05 6:01 
AnswerRe: problem aborting a thread on shutdown Pin
Dan Neely27-Oct-05 7:45
Dan Neely27-Oct-05 7:45 
QuestionBinary Serialization & Webserver Pin
Gilad Kapelushnik27-Oct-05 5:45
Gilad Kapelushnik27-Oct-05 5:45 
QuestionInstaller for C# app Pin
Xiangyang Liu 刘向阳27-Oct-05 5:40
Xiangyang Liu 刘向阳27-Oct-05 5:40 
AnswerRe: Installer for C# app Pin
Joshua Quick27-Oct-05 7:17
Joshua Quick27-Oct-05 7:17 
GeneralRe: Installer for C# app Pin
Xiangyang Liu 刘向阳27-Oct-05 8:12
Xiangyang Liu 刘向阳27-Oct-05 8:12 
GeneralRe: Installer for C# app Pin
Xiangyang Liu 刘向阳27-Oct-05 10:32
Xiangyang Liu 刘向阳27-Oct-05 10:32 
GeneralRe: Installer for C# app Pin
Joshua Quick27-Oct-05 10:51
Joshua Quick27-Oct-05 10:51 
GeneralRe: Installer for C# app Pin
Dave Kreskowiak27-Oct-05 14:25
mveDave Kreskowiak27-Oct-05 14:25 
QuestionC# Best approach to a windows form application Pin
spookas27-Oct-05 5:09
spookas27-Oct-05 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.