vb.net - Please explain how .NET works, using classes -


i run following code snippet.

public shared sub displaydnsconfiguration()  dim adapters networkinterface() = networkinterface.getallnetworkinterfaces() dim adapter networkinterface each adapter in  adapters     dim properties ipinterfaceproperties = adapter.getipproperties()     console.writeline(adapter.description)     console.writeline("  dns suffix................................. :{0}", properties.dnssuffix)     console.writeline("  dns enabled ............................. : {0}", properties.isdnsenabled)     console.writeline("  dynamically configured dns .............. : {0}", properties.isdynamicdnsenabled) next adapter  end sub 'displaydnsconfiguration 

i understand end result, properties printed. don't understand way there.

the following 3 lines ones don't understand:

1. dim adapters networkinterface() = networkinterface.getallnetworkinterfaces() 2. dim adapter networkinterface 3. each adapter in  adapters 

regarding line 1, why networkinterface(), understand when string or integer etc.. not networkinterface(). assume populate "adapters" data returned getallnetworkinterfaces() method.

regarding 2. same above, why doesn't use () in end?

regarding 3. why use adapter in adapters? do? understand loops through interfaces, how?

thanks

dim yourindividualname sometype 

declares variable called yourindividualname type sometype. int , string rather primitive types compared networkinterface, declaring them same.

for example:

dim sometext string 

to declare array (a list) add () type

dim severaltexts string() 

back question:

1:

dim adapters networkinterface() 

declares list (actually array) of networkinterface called adapters, list empty. = networkinterface.getallnetworkinterfaces() fills list.

2:

dim adapter networkinterface 

this declares 1 empty variable of type networkinterface. later used go through list.

3:

for each adapter in adapters     ' stuff next adapter 

this takes first element in list adapters, saves in adapter , stuff between for , next. when there item in list, for takes next one, saves in adapter , on, until reached end of list adapters. between for , next can use adapter e.g. display of properties etc.

a shorter version same:

for each adapter networkinterface in networkinterface.getallnetworkinterfaces()     dim properties ipinterfaceproperties = adapter.getipproperties()     console.writeline(adapter.description)     console.writeline("  dns suffix................................. :{0}", properties.dnssuffix)     console.writeline("  dns enabled ............................. : {0}", properties.isdnsenabled)     console.writeline("  dynamically configured dns .............. : {0}", properties.isdynamicdnsenabled) next adapter 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -