|
God, I just figured out what you meant. You said with this method, I need to manually cast each return value, for example:
Card tempCard = (Card)m_Deck[first].Clone();
Apparently it's because Clone returns an object. Screw that! I'm going to use the latter static method that returns a Card!
Thanks again for all the help.
|
|
|
|
|
You're not annoying at all, i'm happy to help!
I'm glad you figured it out yourself. Of course, i can explain (almost) everything for you, but a real programmer can solve problems, i think.
But that doesn't mean you should stop asking questions though!
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
As Marc said, you should implement the ICloneable interface.
Notice that if you have to do a simple shallow copy as in the case you exposed, you don't have to write your own copy code, but you can use the Object.MemberwiseClone method instead. (You'll have to implement ICloneable anyway though, because MemberwiseClone is protected)
Cheers
|
|
|
|
|
|
That's true (and very cool ), but:
1) The object you want to copy must be Serializable
2) I think (not tested) that it's slower than the usual way of Clone
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Alright, I have an enum called Suit ...
<br />
public enum Suit<br />
{<br />
Hearts = 0,<br />
Diamonds = 1,<br />
Spades = 2,<br />
Clubs = 3,<br />
Null = -1,<br />
}<br />
And I have a function I need to create that will return the correct rank type given an integer.
I have written this function to work with a switch statement:
switch(i)
{
case 0:
return hearts;
...
}
BUT, there must be a much cleaner way to do this, by parsing the enum type from the value - I just don't know the syntax and can't seem to find it.
It must be something like:
Rank r = Enum.Parse(Rank, i);
... of course that doens't work. But it must be something similar.
Any suggestions?
|
|
|
|
|
Its easier than you would expect. Just convert the type:
int i = 0;
Suit suit = (Suit)i; // suit == Suit.Hearts
int index = (int)suit; // index == 0;
|
|
|
|
|
Simply casting to the enum type should work.
Rank r = (Rank)i;
Need to be careful though, this will compile and run even if the value of i is outside the range of Rank.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks! Works perfect! I followed your advice and added error checking to make sure the value is between 0 and NUMRANKS (and 0 AND NUMSUITS for suits).
Thanks again!
|
|
|
|
|
presentation layer passes .data. to business layer.
Business layer validate the .data. if any error exist Alert message should be displayed on screen with option to continue with invalid data. And post the invalid data into a Database table with flag errorfound= .true.
fdfff ff
|
|
|
|
|
DialogResult dr = MessageBox.Show("Your data has errors, Continue?","Error!",MessageBoxButtons.YesNo);
if(dr == DialogResult.Yes)
{
}
HTH
|
|
|
|
|
your code accessing presentation layer code
as long as architecture is concerned business layer should not call any presentation layer code.
do you have any other method
fdfff ff
-- modified at 3:15 Wednesday 2nd November, 2005
|
|
|
|
|
Hello,
I am trying to set up the ODBC Connection. I have the System.Data reference, and I am trying to use System.Data.Odbc directive, but there is no such option as Odbc. Any ideas why?
Thank you.
|
|
|
|
|
|
|
hai, does anyone know how to display a program file eg microsoft document in my window form? thank you
|
|
|
|
|
You could use the Microsoft Word ActiveX object to do this. However, all that's doing is embedding an instance of MS Word into your application. The end user would need MS Word installed before he can run your app. Is this acceptable?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Morality Apart from God
Judah Himango
|
|
|
|
|
Thank you Judah! Actually, I'm new to this. I've imported the microsoft word activeX object but i dont know how to use it. Is there any basic step to build this in C#? Your help is much appreaciated!!
|
|
|
|
|
hai, does anyone how to display a program file eg microsoft document in my window form? thank you
|
|
|
|
|
I want to create a while loop to recieve data.
Here is a button on the webform.
After push the button , the thread start and recieve loop begin.
However, I found it doesn't work.
Why?
|
|
|
|
|
rushing wrote: However, I found it doesn't work.
What doesn't work? You *can* start a thread on the server in your button click handler, but it's not usually recommended as you have to wait for the thread to complete before sending HTML back to the client.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I want to create a server for listening ,and do not need it return html to the client.
|
|
|
|
|
hi
i have a problem with programing in c#
i need to convert a string data such as ( z = x*y+2 ) to a mathematical formule
please help me to solve it
my mail : hosseinyaghmaee@yahoo.com
thanks for your help
|
|
|
|
|
This is not an easy thing to do... ii was trying something similar recently...parsing a formula and tunring it into a graph (eg y=2x or y=x^2).
You have not said what you wan to do with the "formula" after it is parsed...i asuume something like fill in 2 of the 3 variables and have it calculate the third. In which case you need to solve the equation to some extent as well as parse it.
Take a look at a Design Pattern called Interpreter[^] as this is often used for writing programming or scripting languages. You want a simple scripting language with just mathematical operators.
Alternatively, somebody out there would have wriiten this already, you could search google and find something very easily.
|
|
|
|
|
Or use Polish notation for simpler parser. In this kind of notation, you don't need brackets:
( 3 * ( 3 + 7 ) % 2 ) / 17
standard notation
/ % * + 3 7 3 2 17
Polish notation, I think
|
|
|
|