我不知道如何以另一种方法访问我的实例。我有这组代码。
Card rorbcard = new Card();
Deck deck = new Deck();
deck.Shuffle();
rorbcard = deck.TakeCard();
Start0:
Console.Clear();
Console.WriteLine("Allright lets play! Red or black?");
string userValue0 = Console.ReadLine();
switch (userValue0.ToLower())
{
case "red":
{
if (rorbcard.Suit.Equals(Suit.Diamonds))
{
Console.WriteLine("{0},\n Correct give 2 drinks",
rorbcard.ToString());
Thread.Sleep(2000);
}
else if (rorbcard.Suit.Equals(Suit.Hearts))
{
Console.WriteLine("{0},\n Correct give 2 drinks",
rorbcard.ToString());
Thread.Sleep(2000);
}
else
{
Console.WriteLine("{0},\n Wrong sucka take 2 drinks",
rorbcard.ToString());
Thread.Sleep(2000);
}
}
我正在尝试在另一种方法中使用该 rorbcard.ToString() ,但我不知道如何引用它。这是另一种方法。
public void HighLow()
{
//highlow part of the game
Deck deck = new Deck();
deck.Shuffle();
Card highLow = new Card();
highLow = deck.TakeCard();
Start1:
Console.Clear();
Console.WriteLine("Your Hand:");
Grid.WriteAt(rorbcard.ToString(), 0, 1);
Console.WriteLine("\n\nDo you think that the next card will higher,lower,\n or
equal to the {0}. Enter high, low, or equal\n", rorbcard);
string uservalue1 = Console.ReadLine();
switch (uservalue1.ToLower())
{
case "high":
if (highLow.CardNumber > rorbcard.CardNumber) <-----Issue
{
Console.WriteLine("{0},\n Correct give 4 drinks",
highLow.ToString());
Thread.Sleep(2000);
}
else
{
Console.WriteLine("{0},\n Wrong drink 4\n", highLow.ToString());
Thread.Sleep(2000);
}
感谢您花时间调查此事。我被困住了一段时间。