none
Writeline method in C# RRS feed

  • Question

  • Hello,

    Can I have ISSN and Name without using String Interpolation or {0} - {1} in Writeline?

    Tuesday, October 15, 2019 1:24 AM

Answers

All replies

  • That functionality has been available before string interpolation. First MessageBox is similar to the Console.WriteLine you have.

    var p = new Person()
    {
        Identifier = 1,
        FirstName = "Karen",
        LastName = "Payne"
    };
    MessageBox.Show(string.Format("{0} {1} {2}", p.Identifier, p.FirstName, p.LastName));
    MessageBox.Show($"{p.Identifier} {p.FirstName} {p.LastName}");

    See also

    https://docs.microsoft.com/en-us/dotnet/api/system.console.writeline?view=netframework-4.8#System_Console_WriteLine_System_String_System_Object_System_Object_


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 15, 2019 1:34 AM
    Moderator

  • Can I have ISSN and Name without using String Interpolation or {0} - {1} in Writeline?

    Console.WriteLine(ISSN.ToString() + "  " + Name);
    
    

    What is the reason for your question? If you already know how to produce the
    desired output using string interpolation or string composite formatting, why
    are you reluctant to use them? The nature of some of your recent C# questions
    are creating the impression (for me) that you are taking a test or exam. Or
    trying to answer interview questions that test your knowledge of C#.

    Another example is when you asked in another thread:

    "Suppose we cannot use ref here. How can do this without ref keyword?"

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/8f25d1ae-faa9-4468-94c3-97f3683203fe/get-from-array-without-ref-in-c?forum=csharpgeneral#8f25d1ae-faa9-4468-94c3-97f3683203fe

    No explanation or reason was offered as to *why* one could not use ref.

    Since using ref in such cases is typical, and you clearly know how to get
    the desired result using ref, what was the purpose of that question? Under
    what circumstances would one NOT be able or allowed to use ref in such code?

    You were asked by Karen in one of your earlier threads to post code examples
    as actual text in a Code Block to make it easier for those replying to
    create proposed code solutions. Why are you still not doing that?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d7ce23cc-117e-4413-9bdf-f48eed809c2e/narrowing-conversion-in-c?forum=csharpgeneral#d7ce23cc-117e-4413-9bdf-f48eed809c2e

    - Wayne

    • Marked as answer by Arash_89 Wednesday, October 16, 2019 2:21 PM
    Tuesday, October 15, 2019 6:30 AM
  • Thank you for your reply,

    No, I don't have any exam or interview.

    I'm reading C# book from the begging (Pro C# 7: With .NET and .NET Core) and to learn more, I think and consider different situation. 

    I want to be a Web developer. My road map is C#, HTML,CSS,JS then ASP.NET Core.


    Tuesday, October 15, 2019 2:38 PM
  • Thank you for your reply,

    No, I don't have any exam or interview.

    I'm reading C# book from the begging (Pro C# 7: With .NET and .NET Core) and to learn more, I think and consider different situation. 

    I want to be a Web developer. My road map is C#, HTML,CSS,JS then ASP.NET Core.


    C# string interpolation should be used except if you need to target a Framework earlier that 7.x

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 15, 2019 2:42 PM
    Moderator
  • Thank you for your reply,
    .

    You asked:

    >Can I have ISSN and Name WITHOUT using String Interpolation or {0} - {1}

    [Emphasis added.]

    I posted an example showing how to do exactly that, by using string concatenation.

    For some reason you didn't feel that was helpful or answered your question.
    Why not?

    Karen posted an example which USES both methods to which you said you wanted
    ALTERNATIVES. Inexplicably you marked that reply as an answer, even though
    it didn't answer the question you asked. In fact it did the opposite to what
    you wanted. Why did you consider a reply that didn't address your question
    to be an answer?

    You are of course entitled to mark any reply as an answer or as helpful,
    arbitrarily. Or none at all. However if you make it a practice to ignore
    replies that directly answer your questions, while marking as answers
    those replies which don't address your questions - or even as in this case
    provide the opposite of what you asked for - then potential answerers are
    going to find it difficult to discern *exactly* what you want when you post
    questions in the future.

    - Wayne

    Wednesday, October 16, 2019 4:29 AM
  • You are right. 
    Wednesday, October 16, 2019 2:21 PM