Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3989380
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:21:59+00:00 2026-05-20T06:21:59+00:00

I run the following code snippet. Public Shared Sub DisplayDnsConfiguration() Dim adapters As NetworkInterface()

  • 0

I run the following code snippet.

Public Shared Sub DisplayDnsConfiguration() 
Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim adapter As NetworkInterface
For Each adapter In  adapters
    Dim properties As 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 the end result, some properties are printed. However I don’t understand the way there.

The following three lines are the ones I don’t understand:

1. Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
2. Dim adapter As NetworkInterface
3. For Each adapter In  adapters

Regarding line 1, why is the As NetworkInterface(), I understand when it is string or integer etc.. but not NetworkInterface(). Then I assume it populate the “adapters” with the data returned from the GetAllNetworkInterfaces() method.

Regarding 2. Same as above, but why doesn’t it use () in the end?

Regarding 3. Why use the adapter In adapters? What does it actually do? I understand it loops through the interfaces, but how?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:22:00+00:00Added an answer on May 20, 2026 at 6:22 am
    Dim yourIndividualName as SomeType
    

    declares a variable called yourIndividualName which type is SomeType. int and String are rather primitive types compared to a NetworkInterface, but declaring them is the same.

    For example:

    Dim someText as String
    

    To declare an array (a list) simply add () to the type

    Dim severalTexts as String()
    

    Back to your question:

    1:

    Dim adapters As NetworkInterface()
    

    Declares a list (actually an array) of NetworkInterface called adapters, but the list is empty. Then = NetworkInterface.GetAllNetworkInterfaces() fills that list.

    2:

    Dim adapter As NetworkInterface
    

    This declares one empty variable of type NetworkInterface. It is later used to go through the list.

    3:

    For Each adapter In adapters
        ' do some stuff
    Next adapter
    

    This takes the first element in the list adapters, saves it in adapter and does the stuff between For and Next. When there is another item in the list, For takes the next one, saves it in adapter and so on, until it reached the end of the list adapters. Between For and Next you can use adapter to e.g. display some of its properties etc.

    A shorter version that does the same:

    For Each adapter as NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()
        Dim properties As 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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code snippet will result in a run-time: class Vehicle { public void
I have following code snippet that i use to compile class at the run
I run the following code from command line: public class MemoryTest { public static
Let's look at the simple Java code in the following snippet: public class Main
I have the following code snippet: public class A { public static void main(String[]
So I have created the following code snippet to run in a formula to
I want the following code snippet in master page to run if the current
W/hen i run the following code snippet #!/bin/bash if [ foo = foo ];
I am attempting to run the following code snippet: var myVar1 = $.getJSON('myurl', function(json)
The following code snippet gives the error message at run time of: Debug assertion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.