There's a .NET forum here too, where this post might have gotten a quicker response. Anyway, have you read the Help topics on operator overloading? How have they explained it to you in the C# class that you're taking? I've not actually done any operator overloading, but it seems pretty straightforward. I found some examples in the Help, here's an example of an overloaded + operator in a struct (could be used in a class as well, like your Hand class):
public struct Complex
{
public int real;
public int imaginary;
public Complex(int real, int imaginary)
{
this.real = real;
this.imaginary = imaginary;
}
// Declare which operator to overload (+), the types
// that can be added (two Complex objects), and the
// return type (Complex):
public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary);
}
// Override the ToString method to display an complex number in the suitable format:
public override string ToString()
{
return(String.Format("{0} + {1}i", real, imaginary));
}
This should maybe get you started.
~~Bonnie
>This is more a VFPer learning .Net instead of VFP and .Net.
>
>I've started a C# class and I'm having some difficulty with operator overloading.
>
>It's a card game (great real-world example, huh) with a Deck class and a Hand class. Both have card arrays that contain card objects. I'm trying to overload the + operator of the Hand class so that I can get a card from the deck array into the hand array. This is a requirement of the lab, not something I decided to do on my own.
>
>Hand h1 = new Hand();
>Deck d = new Deck();
>
>//Should add a card object to h1.Cards array
>h1+= d.DealCard();
>
>Anybody? Anybody? Bueller?
>
>Thanks,
>
>E.R.