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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:11:07+00:00 2026-05-23T09:11:07+00:00

While working on a project I have come across a way of not having

  • 0

While working on a project I have come across a way of not having to check if a string isnull or empty

dim sb as new stringbuilder
dim bob as string

sb.append((bob & string.empty).padLeft(10, " "))

Here, bob is not instantiated but doesn’t throw a null reference error. In situations like this, is it more readable to do the above code or the below code?

if string.isnullorempty(bob) then
  sb.append(string.empty.padleft(10, " ")
else 
  sb.append(bob.padleft(10," "))
endif

I personally think method #1 is more readable and maintainable. What does the community feel?

  • 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-23T09:11:08+00:00Added an answer on May 23, 2026 at 9:11 am

    Use If() with two parameters to select the first non-null value, e.g.

    If(bob, string.empty).padLeft(10, " ")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While working on an AppEngine connected Android project, I occasionally have problems with RequestFactory
So I have been working on this project for a short while now. I
recently, while working on a db2 -> oracle migration project, we came across this
I've just come across the weirdest behavior in Visual Studio 2010 while working with
I've been working on a home project using CodeIgniter Reactor, and have come to
I'm have been working on solving Project Euler #14 for a while now in
While working a project tonight, I ended up using one .js resource file for
While working on my final project for my AS/400 Course, I encountered this problem
While working on an Xcode project i keep getting the spinning wheel while switching
while working on a school project i ran into a problem using javascript to

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.