Answers for "string format c#"

C#
13

string format c#

using System;

namespace FormatingTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "Name:{0} {1}, Location:{2}, Age:{3}";
            string msg = string.Format(s, "Ram", "Singh", "Mumbai", 32);
            Console.WriteLine("Format Result: {0}", msg);
            Console.WriteLine("\nPress Enter Key to Exit..");
            Console.ReadLine();
        }
    }
}
Posted by: Guest on April-02-2020
7

c# string formatting

name = "Bob";
age = 27;
info = $"Your name is {name} and you are {age} years old";
Posted by: Guest on May-20-2020
0

string.Format() C#

int amount = 14;
String s = String.Format("這是今年吃的第{0}顆柚子",amount);
Console.WriteLine(s);
//這裡會輸出這是今年吃的第14顆柚子
Posted by: Guest on August-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language