powershell - Differences in data types from two approaches -


if declare data type this:

add-type -typedefinition "public class mytest {}" 

and create object , data type, mytest, expect:

(new-object mytest).gettype().name 

but if refer type directly...

[mytest].gettype().name 

i runtimetype. can explain what's going on here?

this has nothing add-type cmdlet in particular; applies powershell types:

ps > (1).gettype().name int32 ps > [int].gettype().name runtimetype 

things (new-object mytest) , 1 instances of specific types. calling .gettype() on them returning type of instances.

things [mytest] , [int] instances of runtimetype class, represents powershell runtime types (things in [...]). why [mytest].gettype().name returning runtimetype. getting type of mytest class itself, not instances.

below visual breakdown:

new-object mytest  # mytest instance [mytest]           # runtimetype instance 1                  # integer instance [int]              # runtimetype instance 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -