2016-10-27 7 views
0

ImはVisual Studioで文字列をintに変換しようとしていますが、いつでもその文字列をrefrenceしようとしているものを拾うようです。文字列をIntに変換しようとしています

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace WindowsFormsApplication5 
{ 
public partial class Form1 : Form 
{ 
    public Form1() 
    { 
     InitializeComponent(); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 

    } 

    private void points1_TextChanged(object sender, EventArgs e) 
    { 

    } 



    private void button1_Click(object sender, EventArgs e) 
    { 
     int x = Int32.Parse(textbox1.Text); 
     resultBox.Text = 
    } 
} 

}

ソリューションオンラインのdidntはまったく機能しているように見えるので、私は本当に、何かを見つける傾けます。

+2

*これを別の言い方で説明することはできませんか?あなたが何を意味しているのか理解できない。 –

+0

さらに、「オンラインのソリューションはまったく機能していないので、何も見つかりません。」不明です。どのような解決策がありますか? – HimBromBeere

+1

あなたのxはintに変換されています...あなたの問題は何ですか? – kurakura88

答えて

1

あなたはint.TryParseを使用して試すことができます:成功は、結果としての地位をtextbox1.Textを置く上、inttextbox1.Textを解析を試してみてください。失敗したら、"?"

+0

はい、正しいです。 –

1

これを試してみてください。

int x = Int32.Parse(TextBox1.Text); 

またはこれです。

int x = 0; 

    Int32.TryParse(TextBox1.Text, out x); 
関連する問題