Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 3, 2014 22:54
Show Gist options
  • Save Fhernd/21d37e589220739bb0e6 to your computer and use it in GitHub Desktop.
Save Fhernd/21d37e589220739bb0e6 to your computer and use it in GitHub Desktop.
Comprobación del tipo de un objeto con GetType de Object en C#.
using System;
namespace Recetas.Cap03
{
internal class UsoComprobacionGetType
{
public static void Main()
{
int num1 = 13;
int num2 = 83;
long num3 = 19;
Console.WriteLine ("¿`num1` y `num2` son del mismo tipo?: {0}",
Object.ReferenceEquals(num1.GetType(),num2.GetType()));
Console.WriteLine ("¿`num1` y `num3` son del mismo tipo?: {0}",
Object.ReferenceEquals(num1.GetType(),num3.GetType()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment