Logo

Programming-Idioms

History of Idiom 94 > diff from v13 to v14

Edit summary for version 14 by :
[Csharp] formatting

Version 13

2016-02-17, 10:20:45

Version 14

2016-02-18, 16:58:02

Idiom #94 Print type of variable

Print the name of the type of x. Explain if it is a static type or dynamic type.

This may not make sense in all languages.

Idiom #94 Print type of variable

Print the name of the type of x. Explain if it is a static type or dynamic type.

This may not make sense in all languages.

Code
object variable1 = new DateTime(2015,3,10);

System.Console.WriteLine(variable1.GetType());
Code
object variable1 = new DateTime(2015,3,10);

System.Console.WriteLine(variable1.GetType());
Code
int a = 0;
String b = "str";
System.out.println(((Object)a).getClass().getName());
System.out.println(b.getClass().getName());
Code
int a = 0;
String b = "str";
System.out.println(((Object)a).getClass().getName());
System.out.println(b.getClass().getName());
Doc URL
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html
Doc URL
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html