Como posso obter o tipo de dados de uma variável em c #?
Como posso descobrir qual tipo de dados alguma variável está mantendo? (por exemplo, int, string, char etc.)
Eu tenho algo parecido com isso agora:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Testing
{
class Program
{
static void Main()
{
Person someone = new Person();
someone.setName(22);
int n = someone.getName();
Console.WriteLine(n.typeOf());
}
}
class Person
{
public int name;
public void setName(int name)
{
this.name = name;
}
public int getName()
{
return this.name;
}
}
}