2
How to put a variable inside the message box? The code comes below I think is self-explanatory.
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 A12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var c;
c = 23;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("{0}", c);
}
}
}
Just to complement: "print the variable in a different way", this way is called String interpolation.
– Thiago Lunardi
Interesting, I didn’t know. @Thiagolunardi
– Francisco