Wrox Programmer Forums
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 17th, 2013, 06:32 PM
Registered User
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch10CardLib - Deck class

Hi all, I am new to C# and new to this forum. Decided to learn c# two months ago and started with Beginning Visual C#2010. Didnt need any help till now. Maybe its really simple, but I just dont see it. I just dont get the following in bold (the 13 at least makes sence, feeling whise, since there are 13 cards per suit, but I really cant place the -1):

public class Deck
    private Card[] cards;
    public Deck()
        cards = new Card[52];
        for (int suitVal = 0; suitVal < 4; suitVal++)
            for (int rankVal = 1; rankVal < 14; rankVal++)
                 cards[suitVal * 13 + rankVal -1] = new Card((Suit)suitVal,
I could also a check up so could everyone be so kind to explain what happens line by line and put special focus on the part in bold? Much appreciated.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3 - Modeling a deck of cards saltima BOOK: Beginning Mac OS X Programming 0 August 15th, 2012 12:48 PM
[Modeling a Deck of Cards] question Almakos BOOK: Beginning iOS Game Development 2 May 3rd, 2012 01:44 AM
Chapter 3, pg 68 - Shuffling the Deck of Cards maconspace BOOK: Beginning iOS Game Development 11 March 11th, 2012 08:28 AM
calling a parent class method from a child class (Zend Cert) crmpicco Beginning PHP 2 July 30th, 2010 04:22 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.