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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:53:13+00:00 2026-06-03T05:53:13+00:00

What is happening below? using System; using System.Collections.Generic; using System.Linq; using System.Text; public class

  • 0

What is happening below?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class DotNetPad
{
    public static void Main(string[] args)
    {
        int i = 10;
        string k = "Test";
        Console.WriteLine(i+k);
        Console.WriteLine(k+i);
    }
}

i is being converted to string in both cases. I am confusing myself with the idea of operator precedence (although this example doesn’t show much of that) and evaluation direction. Sometimes evaluation happens from left-to-right or vice versa. I don’t exactly know the science of how the expression is evaluated…

Why is i converted to string in the above example, and not actually giving a compilation error?

  • 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-03T05:53:15+00:00Added an answer on June 3, 2026 at 5:53 am

    From the C# spec – section 7.7.4 Addition operator:

    String concatenation:

    string operator +(string x, string y);
    string operator +(string x, object y);
    string operator +(object x, string y);
    

    The binary + operator performs string concatenation when one or both
    operands are of type string. If an operand of string concatenation is
    null, an empty string is substituted. Otherwise, any non-string
    argument is converted to its string representation by invoking the
    virtual ToString method inherited from type object. If ToString
    returns null, an empty string is substituted.

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

Sidebar

Related Questions

I am trying to understand what is happening in the getter below, this is
This is my below code, I am confuse why this thing is happening. In
Something strange is happening in my code where I'm using a StackTrace. It's almost
I am using a generic ListView sorter implementing the IComparer interface. Is this working
This is a small piece of code shown below which is using do while
I'm having kind of a dumb problem. I am using the below code to
I have an algorithm of which I'm using System.Diagonstics to time - via the
I have no idea why this is happening, but I created the below code
I'm using the below code to put an overlay on my MapView. For some
INITIAL QUESTION (UPDATED BELOW) I'm using an AutoPopulatingList list to instatiate an object invoking

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.