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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:12:18+00:00 2026-05-11T04:12:18+00:00

Had a coworker ask me this, and in my brain befuddled state I didn’t

  • 0

Had a coworker ask me this, and in my brain befuddled state I didn’t have an answer:

Why is it that you can do:

string ham = 'ham ' + 4; 

But not:

string ham = 4; 

If there’s an implicit cast/operation for string conversion when you are concatenating, why not the same when assigning it as a string? (Without doing some operator overloading, of course)

  • 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. 2026-05-11T04:12:18+00:00Added an answer on May 11, 2026 at 4:12 am

    When concatenating the compiler turns the statement 'ham' + 4 into a call to String.Concat, which takes two object parameters, so the value 4 is boxed and then ToString is called on that.

    For the assignment there is no implicit conversion from int to string, and thus you cannot assign 4 to a string without explicitly converting it.

    In other words the two assignments are handled very differently by the compiler, despite the fact that they look very similar in C#.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer JLS: An identifier is an unlimited-length sequence of Java letters… May 11, 2026 at 11:22 am
  • added an answer This should do it: SELECT s.id, s.title, s.desc FROM Section… May 11, 2026 at 11:22 am
  • added an answer Ok, I found the answer. Add the not-found='ignore' attribute to… May 11, 2026 at 11:22 am

Related Questions

Had a coworker ask me this, and in my brain befuddled state I didn't
Today I had a coworker suggest I refactor my code to use a label
A coworker of mine has had issue with Mootools being backward compatible and I
I had a discussion with some colleagues mentioning that there are not too many
I had a plugin installed in Visual Studio 2008, and it created some extra
I had a discussion with a developer earlier today re identifying TCP packets going
I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a
Lifehacker had a post a couple days ago asking people about the best mouse
I had a discussion a few weeks back with some co-workers on refactoring, and
I had a problem that was partially solved. To explain it quickly : I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.