Please refer to the following sectionVbsCode:
SetOBJ = Createobject ("System. Collections. arraylist") OBJ. Add ("This is a test") OBJ. Add (1) OBJ. Add (OBJ) Msgbox OBJ (0) Msgbox OBJ (1) Msgbox OBJ (2). tostring () |
The Code tries to create Arraylist Of . Net Object, and then add several different types of objects in this Arraylist . Why can we Vbs Used in . Net What about built-in types? This is because . Net After installation Com Visible types have been registered. Open the Registry Editor and you will see System_class_root There are many System. Starting Progid , These Progid Of CLSID Of Inprocserver All Mscoree. dll In other words VB Script In the script Createobject When an object is called, Com Library passed Mscoree. dll Load CLR And then create System. Collections. arraylist Object and finally return VB ScriptProgram.
and msgbox OBJ (1) there are also xuanjicang. You must know that in the arraylist only Object type data can be saved, that is, obj. add (1) after the call is completed, arraylist the second element is a Object type, why msgbox OBJ (1) but it can be correctly displayed 1 ? the object type contains several functions, such as equals , gethashcode why other functions are not called, instead, what about calling the tostring function? This is because . net tostring function dispid set to zero, in com , dispid 0 is the default function.