Click here to Skip to main content
16,006,883 members
Home / Discussions / C#
   

C#

 
GeneralMore Collision (XNA) Pin
MasterSharp17-Mar-08 5:01
MasterSharp17-Mar-08 5:01 
GeneralRe: More Collision (XNA) Pin
Christian Graus17-Mar-08 9:15
protectorChristian Graus17-Mar-08 9:15 
GeneralRe: More Collision (XNA) [modified] Pin
MasterSharp17-Mar-08 10:09
MasterSharp17-Mar-08 10:09 
Generalto return or not to return something Pin
pauli17-Mar-08 4:58
pauli17-Mar-08 4:58 
GeneralRe: to return or not to return something Pin
Rob Philpott17-Mar-08 6:20
Rob Philpott17-Mar-08 6:20 
GeneralRe: to return or not to return something Pin
Simon P Stevens17-Mar-08 6:55
Simon P Stevens17-Mar-08 6:55 
GeneralRe: to return or not to return something [modified] Pin
pauli17-Mar-08 23:01
pauli17-Mar-08 23:01 
GeneralRe: to return or not to return something Pin
Simon P Stevens18-Mar-08 6:07
Simon P Stevens18-Mar-08 6:07 
pauli wrote:
What type is theHands? I assume Collection is a type?
Collection theHands; // why not = new Collection(); ?


Collection is a generic type. This means that when you create a collection object you have to also provide a type parameter. The collection will then contain objects of the type you specified when you created it. So for a collection of ints you would define it like this:

Collection<int> myintcollection = new Collection<int>();
Don't forget to include a using statement at the top of the file to link to the namespace
using System.Collections.ObjectModel;

Google around for a tutorial on generics to help you understand this. There's loads out there.

pauli wrote:
How do I refer to each hand?


Just like you would with an array.
theHands[1];

Or using a foreach loop.
<br />
foreach(PlayerHand hand in theHands)<br />
{<br />
    // Do something with the hand object here.<br />
{<br />


pauli wrote:
How do I assign a value to theHands?


Once you've created the new collection like this
Collection<PlayerHand> theHands = new Collection<PlayerHand>()

you can call the Add(...) method to add new hands to the collection.
PlayerHand hand1 = new PlayerHand();<br />
theHands.Add(hand1);<br />


pauli wrote:

aHand[i].Cards(j).set =CardArray[4 * j + i];

the above does not work - the error is Cards is a property and i am trying to use it as a method


You're doing exactly what it says. Cards is a property of the hand object. By using round brackets your trying to call a method called Cards (which doesn't exist).

The Cards property is giving you access to a collection object containing all the cards in the hand, which you then want to access with a indexer (square brackets) to get the specific card you want to look at.

If you want to add a card to the collection use the .Add method.
aHand[i].Cards.Add(put the card you want to add here);

pauli wrote:
otherwise, I'm back to VB6, forever !


Noooooooooo........ OMG | :OMG:

Simon

Generalgeneric collection - .net 2.0 Pin
arkiboys17-Mar-08 4:22
arkiboys17-Mar-08 4:22 
GeneralRe: generic collection - .net 2.0 Pin
Luc Pattyn17-Mar-08 4:29
sitebuilderLuc Pattyn17-Mar-08 4:29 
QuestionActive Directory "login" from C# application Pin
User 137680017-Mar-08 3:52
User 137680017-Mar-08 3:52 
GeneralResource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 3:45
Kolobock17-Mar-08 3:45 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Luc Pattyn17-Mar-08 3:55
sitebuilderLuc Pattyn17-Mar-08 3:55 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 4:07
Kolobock17-Mar-08 4:07 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Luc Pattyn17-Mar-08 4:25
sitebuilderLuc Pattyn17-Mar-08 4:25 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 8:32
Kolobock17-Mar-08 8:32 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Luc Pattyn17-Mar-08 8:44
sitebuilderLuc Pattyn17-Mar-08 8:44 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 10:18
Kolobock17-Mar-08 10:18 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Rob Philpott17-Mar-08 4:10
Rob Philpott17-Mar-08 4:10 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 8:34
Kolobock17-Mar-08 8:34 
GeneralRe: Resource leak (handles count) in simple .NET application Pin
Kolobock17-Mar-08 23:57
Kolobock17-Mar-08 23:57 
GeneralIP Camera with C# Pin
sher1217-Mar-08 3:44
sher1217-Mar-08 3:44 
GeneralRe: IP Camera with C# Pin
Luc Pattyn17-Mar-08 3:59
sitebuilderLuc Pattyn17-Mar-08 3:59 
GeneralScreen Shot Pin
sjs4u17-Mar-08 2:18
sjs4u17-Mar-08 2:18 
GeneralRe: Screen Shot Pin
ritz123417-Mar-08 2:45
ritz123417-Mar-08 2:45 

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.