Click here to Skip to main content
14,693,599 members
Home » Discussions » C#
   

C#

 
GeneralRe: Card shuffle program code help needed (code included) Pin
Brian_TheLion8-Jun-20 20:01
MemberBrian_TheLion8-Jun-20 20:01 
GeneralRe: Card shuffle program code help needed (code included) Pin
Richard Deeming8-Jun-20 23:16
mveRichard Deeming8-Jun-20 23:16 
GeneralRe: Card shuffle program code help needed (code included) Pin
Brian_TheLion11-Jun-20 19:20
MemberBrian_TheLion11-Jun-20 19:20 
AnswerRe: Card shuffle program code help needed Pin
OriginalGriff7-Jun-20 5:11
mveOriginalGriff7-Jun-20 5:11 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion7-Jun-20 16:37
MemberBrian_TheLion7-Jun-20 16:37 
GeneralRe: Card shuffle program code help needed Pin
OriginalGriff7-Jun-20 21:38
mveOriginalGriff7-Jun-20 21:38 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion8-Jun-20 20:12
MemberBrian_TheLion8-Jun-20 20:12 
GeneralRe: Card shuffle program code help needed Pin
F-ES Sitecore9-Jun-20 3:31
mveF-ES Sitecore9-Jun-20 3: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

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

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;

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

GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion9-Jun-20 20:56
MemberBrian_TheLion9-Jun-20 20:56 
GeneralRe: Card shuffle program code help needed Pin
Brian_TheLion11-Jun-20 19:17
MemberBrian_TheLion11-Jun-20 19:17 
QuestionBest way to store methods in a database? Pin
arnold_w5-Jun-20 23:42
Memberarnold_w5-Jun-20 23:42 
QuestionRe: Best way to store methods in a database? Pin
Richard MacCutchan5-Jun-20 23:58
mveRichard MacCutchan5-Jun-20 23:58 
AnswerRe: Best way to store methods in a database? Pin
arnold_w6-Jun-20 0:56
Memberarnold_w6-Jun-20 0:56 
GeneralRe: Best way to store methods in a database? Pin
Richard MacCutchan6-Jun-20 1:10
mveRichard MacCutchan6-Jun-20 1:10 
GeneralRe: Best way to store methods in a database? Pin
arnold_w6-Jun-20 1:14
Memberarnold_w6-Jun-20 1:14 
AnswerRe: Best way to store methods in a database? Pin
Member 79891226-Jun-20 6:22
MemberMember 79891226-Jun-20 6:22 
GeneralRe: Best way to store methods in a database? Pin
Richard MacCutchan6-Jun-20 6:26
mveRichard MacCutchan6-Jun-20 6:26 
AnswerRe: Best way to store methods in a database? Pin
Eddy Vluggen6-Jun-20 0:48
professionalEddy Vluggen6-Jun-20 0:48 
AnswerRe: Best way to store methods in a database? Pin
Richard Deeming8-Jun-20 1:05
mveRichard Deeming8-Jun-20 1:05 
GeneralRe: Best way to store methods in a database? Pin
#realJSOP10-Jun-20 0:25
mva#realJSOP10-Jun-20 0:25 
GeneralRe: Best way to store methods in a database? Pin
Member 798912210-Jun-20 11:58
MemberMember 798912210-Jun-20 11:58 
QuestionMulti programming language Pin
Member 148535394-Jun-20 7:13
MemberMember 148535394-Jun-20 7:13 
AnswerRe: Multi programming language Pin
Richard MacCutchan4-Jun-20 7:15
mveRichard MacCutchan4-Jun-20 7:15 
AnswerRe: Multi programming language Pin
OriginalGriff4-Jun-20 7:35
mveOriginalGriff4-Jun-20 7:35 
AnswerRe: Multi programming language Pin
Pete O'Hanlon4-Jun-20 22:43
subeditorPete O'Hanlon4-Jun-20 22: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.