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 958161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:49:08+00:00 2026-05-16T00:49:08+00:00

I have the following VB.NET code (but for each loops are in most languages,

  • 0

I have the following VB.NET code (but for each loops are in most languages, thus the language-agnostic tag):

  Public Function VerifyServiceName(ByRef sMachineName As String, ByRef sServiceName As String) As Boolean
    Dim asServices As System.ServiceProcess.ServiceController() = System.ServiceProcess.ServiceController.GetServices(sMachineName)
    Dim bVerified As Boolean = False
    For Each sService In asServices
      If sService.DisplayName = sServiceName Then bVerified = True
    Next
    Return bVerified
  End Function

If I have X number of services to loop through, and my service name is #3. Is it better to have multiple return statements or an exit for? Or is there a more efficient way of writing this function?

I know that the time difference between looping X times and looping through 3 times could be marginal for what I am doing, but I always have performance on the brain.

  • 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-16T00:49:09+00:00Added an answer on May 16, 2026 at 12:49 am

    Found more discussion here about the subject. I guess I am not that proficient at searching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code at JSfiddle: http://jsfiddle.net/ACG2D/ $(document).ready(function() { $('.testThis').click(function() { $('.regexValidation').each(function() {
I have following asp.net code but it gives error when I change dropdown selected
I have the following code which is created with a datalist control: http://jsfiddle.net/vmE2E/1/ But
I have the following code in my ASP.NET project public sealed class IoC {
I have the following code in a full .NET framework solution: public delegate int
I have the following code in VB.NET <#@ template debug=false hostspecific=true language=VB #> <#@
ASP.NET 4.0 Webforms project. I have the following in my code-behind. public partial class
I have following code that I am compiling in a .NET 4.0 project namespace
Anything I have tried didn't work. Currenly I have following code to change asp.net
I have the following code setup: http://jsfiddle.net/bABHU/2/ Had to change it a little bit

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.