小编Sim*_*ame的帖子

在C#中将字符串转换为int

我是C#的新手,我想做一个纸牌游戏.我有什么是卡(串)有了这样一份名单c6, s3, h11, d13,其中character represents the colournumber represents the value.当按下按钮时,程序从列表中获取随机字符串并将其显示在文本框中.从那里开始,游戏的目的是猜测下一张随机卡是否会比之前的卡具有更高的值或更低的值.

我想要做的是从文本框中取出字符串并将其转换为int,以便我可以将前一张卡的值与新卡的值进行比较.唯一的问题是我如何摆脱cin c6所以我可以通过使用转换它parse.

这是我的代码.

public partial class MainWindow : Window
{
    static Random rndmlist = new Random();
    Random rndm = new Random();
    List<string> deck = new List<string>();
    int score = 0;
    public MainWindow()
    {
        InitializeComponent();
    }

    private void test_Click(object sender, RoutedEventArgs e)
    {
        //disregard this
        foreach (string j in deck)
        {
            testbox.Text += j + ", ";
        }
    }

    private …
Run Code Online (Sandbox Code Playgroud)

c# string wpf int

1
推荐指数
1
解决办法
7271
查看次数

标签 统计

c# ×1

int ×1

string ×1

wpf ×1