Click here to Skip to main content
15,884,836 members
Home / Discussions / C#
   

C#

 
GeneralRe: Card shuffle program code help needed (code included) Pin
Brian_TheLion8-Jun-20 19:01
Brian_TheLion8-Jun-20 19:01 
GeneralRe: Card shuffle program code help needed (code included) Pin
Richard Deeming8-Jun-20 22:16
mveRichard Deeming8-Jun-20 22:16 
GeneralRe: Card shuffle program code help needed (code included) Pin
Brian_TheLion11-Jun-20 18:20
Brian_TheLion11-Jun-20 18:20 
AnswerRe: Card shuffle program code help needed Pin
OriginalGriff7-Jun-20 4:11
mveOriginalGriff7-Jun-20 4:11 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion7-Jun-20 15:37
Brian_TheLion7-Jun-20 15:37 
GeneralRe: Card shuffle program code help needed Pin
OriginalGriff7-Jun-20 20:38
mveOriginalGriff7-Jun-20 20:38 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion8-Jun-20 19:12
Brian_TheLion8-Jun-20 19:12 
GeneralRe: Card shuffle program code help needed Pin
F-ES Sitecore9-Jun-20 2:31
professionalF-ES Sitecore9-Jun-20 2:31 
That's just the basic type info for what you're hovering over. When you hover over deck1 it shows the info for that object. If you want to know what "deck1[x]" is then you can highlight the whole string including the square brackets, right click and select "Quick Watch" from the context menu.

Another debugging tip is that compound statements like this

C#
Console.Write("0-19)", deck1.DealCard());


are harder to debug. While still in the coding process it will often help to split things up into individual lines

C#
Card card = deck1.DealCard();
Console.Write("0-19)", card);


You can now inspect "card" to see what DealCard has returned. If it looks like what you expect then you know it is the Console.Write that isn't doing what you expect. By splitting the code into two separate stages you can test them separately...you can test DealCard is doing what you want, then Console.Write. With your original code you are doing two things at once so it is harder to know which of those things is failing. Once you have your bugs ironed out and the code working, you can go back to the code in line if you wish.

The reason your Console.Write isn't working is because you are using the two param method, so the first param ("0-19)") is the "format" and the second param ("card") is the data you want to show in that format. However "0-19)" is not a proper formatting string so all you will get is that text out verbatim. A formatting string has placeholders for the values, so {0} for the first param, {1} for the second etc.

To see this in action try;

C#
Card card = deck1.DealCard();
Console.Write("card {0} = {1} ", i, card);

GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion9-Jun-20 19:56
Brian_TheLion9-Jun-20 19:56 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion11-Jun-20 18:17
Brian_TheLion11-Jun-20 18:17 
QuestionBest way to store methods in a database? Pin
arnold_w5-Jun-20 22:42
arnold_w5-Jun-20 22:42 
QuestionRe: Best way to store methods in a database? Pin
Richard MacCutchan5-Jun-20 22:58
mveRichard MacCutchan5-Jun-20 22:58 
AnswerRe: Best way to store methods in a database? Pin
arnold_w5-Jun-20 23:56
arnold_w5-Jun-20 23:56 
GeneralRe: Best way to store methods in a database? Pin
Richard MacCutchan6-Jun-20 0:10
mveRichard MacCutchan6-Jun-20 0:10 
GeneralRe: Best way to store methods in a database? Pin
arnold_w6-Jun-20 0:14
arnold_w6-Jun-20 0:14 
AnswerRe: Best way to store methods in a database? Pin
kalberts6-Jun-20 5:22
kalberts6-Jun-20 5:22 
GeneralRe: Best way to store methods in a database? Pin
Richard MacCutchan6-Jun-20 5:26
mveRichard MacCutchan6-Jun-20 5:26 
AnswerRe: Best way to store methods in a database? Pin
Eddy Vluggen5-Jun-20 23:48
professionalEddy Vluggen5-Jun-20 23:48 
AnswerRe: Best way to store methods in a database? Pin
Richard Deeming8-Jun-20 0:05
mveRichard Deeming8-Jun-20 0:05 
GeneralRe: Best way to store methods in a database? Pin
#realJSOP9-Jun-20 23:25
mve#realJSOP9-Jun-20 23:25 
GeneralRe: Best way to store methods in a database? Pin
kalberts10-Jun-20 10:58
kalberts10-Jun-20 10:58 
QuestionMulti programming language Pin
Member 148535394-Jun-20 6:13
Member 148535394-Jun-20 6:13 
AnswerRe: Multi programming language Pin
Richard MacCutchan4-Jun-20 6:15
mveRichard MacCutchan4-Jun-20 6:15 
AnswerRe: Multi programming language Pin
OriginalGriff4-Jun-20 6:35
mveOriginalGriff4-Jun-20 6:35 
AnswerRe: Multi programming language Pin
Pete O'Hanlon4-Jun-20 21:43
mvePete O'Hanlon4-Jun-20 21:43 

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.