準備
(なし)
デザイン
- フォーム (Form1) にボタン (button1) を配置します。
サンプルコード (C#)
namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
bool v01 = true;
sbyte v02 = 0;
byte v04 = 0;
char v05 = ' ';
short v06 = 0;
ushort v09 = 0;
int v10 = 0;
uint v12 = 0;
long v14 = 0;
ulong v16 = 0;
float v17 = 0;
double v18 = 0;
decimal v20 = 0;
listBox1.Items.Add("v01: " + v01.GetType().FullName);
listBox1.Items.Add("v02: " + v02.GetType().FullName);
listBox1.Items.Add("v04: " + v04.GetType().FullName);
listBox1.Items.Add("v05: " + v05.GetType().FullName);
listBox1.Items.Add("v06: " + v06.GetType().FullName);
listBox1.Items.Add("v09: " + v09.GetType().FullName);
listBox1.Items.Add("v10: " + v10.GetType().FullName);
listBox1.Items.Add("v12: " + v12.GetType().FullName);
listBox1.Items.Add("v14: " + v14.GetType().FullName);
listBox1.Items.Add("v16: " + v16.GetType().FullName);
listBox1.Items.Add("v17: " + v17.GetType().FullName);
listBox1.Items.Add("v18: " + v18.GetType().FullName);
listBox1.Items.Add("v20: " + v20.GetType().FullName);
}
}
}
解説
.NET の型の別名が各言語で独自に定義されています。今回は C# の型で変数を宣言して、その型名を出力しています。
結果
動作確認環境
Visual Studio 2022 Professional (.NET 7 C#11)
ログ
初版:2016.01.03 Visual Studio 2015 Professional (C# 6.0)
