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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:22:31+00:00 2026-05-26T12:22:31+00:00

this is probably quite a simple problem, however, I can’t figure out how to

  • 0

this is probably quite a simple problem, however, I can’t figure out how to get around this. Basically, my class Client requires a work address value, however, it’s not 100% required when creating a client. In creating the variable to be used for the object creation i’m using a string value which will then get the value from a text box. I am then checking to see if the textbox is empty, if it is, the string value of the variable is just a whitespace. Else, it’s the textbox value.

string homeAdd;
if(homeAddressText.Text == String.Empty)
{
    homeAdd = " ";
}
else if (homeAddressText.Text != String.Empty)
{
    homeAdd = homeAddressText.Text;
}

As seen here..

However, when I go to create the client object using this variable, I get an error saying ‘use of unassigned local variable ‘homeAdd’.

Client client = new Client(firstN, lastN, homeAdd, workAdd, email, homeP, cellP);

Is there a simple way I can do the checking I require and still use the variable?

Thanks in advance guys/gals.

  • 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-26T12:22:31+00:00Added an answer on May 26, 2026 at 12:22 pm

    Change the whole else if line to just:

    else
    

    The two conditions are exact opposites. Your code would work (but is verbose) in theory, provided the textbox is only touched on the UI thread. However, the compiler can not confirm this.

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

Sidebar

Related Questions

This is probably something extremely simple but I can't get my head around it
This is probably something really simple, however I am quite new to PHP, and
This is probably quite simple but I've googled and can't find an answer. I
I have a pretty simple general programming problem, yet I can't quite get the
This is probably quite a simple problem, but Im quite new to R. I
This is probably quite a simple problem, but it's causing me to scratch my
This is probably quite simple, but I just don't know how to do this...
This is probably quite simple but I haven't yet been able to wrap my
This problem is probably very simple to solve but it is not clear to
Ok, this has got to be a super simple problem. I just can't seem

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.