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

  • Home
  • SEARCH
  • 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 8429435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:20:17+00:00 2026-06-10T05:20:17+00:00

What’s the return value when I do an assignment? For example, can I do

  • 0

What’s the return value when I do an assignment?

For example, can I do this? (i.e. the assignment returns the value being assigned)

Dim a As Integer = 1
Dim b As Integer = 2
a = b = 3

The question came up when I wrote this code today:

Dim updates = GetUpdates()
While updates.Count > 0
    Foo.ApplyUpdates(updates)
    updates = GetUpdates()
End While

I kind of wish I could have written it this way…

While (updates = GetUpdates).Count > 0
    Foo.ApplyUpdates(updates)
End While

I know it’s not as clean… (and I totally never declared updates) but it got me curious about how assignments work in .NET… is it a function with a return value? If so… what does it return?

Edit

I gave the first chunk of code a try. It looks like the compiler interprets it as assigning the result of comparing b and 3 to a… which is a compiler error of course.

And for the second code chunk, I get that the operator = is not defined for what ever type updates is… i.e. it thinks it’s a comparison, not an assignment.

So to add to my question, why does it work this way? Is it just because vb.net overloads the symbol = with two meanings (assignment and comparison)?

  • 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-06-10T05:20:19+00:00Added an answer on June 10, 2026 at 5:20 am

    about how assignment working in .NET.

    This is actually about how assignment works in VB, not in .NET.

    This does not work in VB.Net. The = Operator in VB.Net merely “assigns the value on its right to the variable or property on its left.”

    What’s the return value when I do an assignment?

    As seen in the above statement, the assignment operator does not return a value in VB.Net.

    Note that this differs from other .NET languages. For example, in C#, the assignment = Operator does what you’re describing, and “stores the value of its right-hand operand in the storage location, property, or indexer denoted by its left-hand operand and returns the value as its result.”

    Dim a As Integer
    Dim b As Integer
    a = b = 3
    

    Note that, with Option Strict specified, this will actually be an error: “Option Strict On disallows implicit conversions from ‘Boolean’ to ‘Integer’.”

    This is because VB.Net sees this as two operations – it’s basically trying to do:

    Dim a As Integer
    Dim b As Integer
    
    Dim temp as Boolean
    temp = (b = 3)
    a = temp
    

    So to add to my question, why does it work this way? Is it just because vb.net overloads the symbol = with two meanings (assignment and comparison)?

    Well, it’s how the language was designed. I suspect that you are correct, though, and since the same operator (=) is used as an assignment and a comparison is why VB was made this way. However, the original VB language was this way, and to keep the syntax for VB.Net the same (or as close as possible), I suspect this behavior was carried forward.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.