我的整数值没有显示在我的 black jack 程序中 c#

The value of my integers is not showing in my black jack program c#

我正在尝试完成一个非常简单的 black jack 程序。我似乎遇到麻烦的是没有为卡一和二生成数字。到目前为止,这是我的代码:

namespace Black_Jack
{
class Program
{
    static void Main(string[] args)
    {
        int card1, card2;
        float total;          

            Console.WriteLine("Value of card one:");
            Random card = new Random();
            card1 = card.Next(1, 12);
            Console.WriteLine("Value of card two:");
            card2 = card.Next(1, 12);
            total = card1 + card2;            

            {
                if (total >= 21)
                {
                    Console.WriteLine("You Busted!");
                }
                else if (total == 21)
                {
                    Console.WriteLine("Black Jack! You Win Mr. Vegas!");
                }
                else if (total < 21)
                {
                    Console.WriteLine("I'll stand. Show me your cards dealer!");
                }
            }

            Console.ReadLine();

我不太确定我的问题出在哪里,所以对我做错了什么的解释会很有帮助。另外,如果还有什么需要清理的,请告诉我。

尝试将 total 声明为 int

Int total;
total = card1 + card2; // assign integers sum to integer variable

或者你可以使用转换

Total = (float)(card1 + card2); // converts integers sum to float

并且,

card1 = card.Next(1, 12);

在这一行之后打印你的随机数字

Console.WriteLine(card1); // similar for both card