本文介绍了字符串格式化 - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#1 - string str =ABCDVER+1;

#2 - string str2 =ABCDVER; string str3 =1;

#3 - string str1 = string.format({0} {1},str2,str3);



第1行和第2行给出了相同的答案?请确认。



谢谢

Arun



我是什么尝试过:



#1 - 字符串str =ABCDVER+1;

#2 - 字符串str2 =ABCDVER; string str3 =1;

#3 - string str1 = string.format({0} {1},str2,str3);



第1行和第2行给出了相同的答案?请确认。



谢谢

Arun

#1 - string str = "ABCDVER" + "1";
#2 - string str2 = "ABCDVER"; string str3 = "1";
#3 - string str1 = string.format("{0}{1}",str2,str3);

Line#1 and Line#2 gives same answer?. Please confirm.

Thanks
Arun

What I have tried:

#1 - string str = "ABCDVER" + "1";
#2 - string str2 = "ABCDVER"; string str3 = "1";
#3 - string str1 = string.format("{0}{1}",str2,str3);

Line#1 and Line#2 gives same answer?. Please confirm.

Thanks
Arun

推荐答案

string str = "ABCDVER" + "1";
string str2 = "ABCDVER"; string str3 = "1";
string str1 = string.Format("{0}{1}", str2, str3);
if (str == str1) Console.WriteLine("Yes");
else Console.WriteLine("No");


class Program
{
    static void Main(string[] args)
    {
    string str = "ABCDVER" + "1";
    string str2 = "ABCDVER"; string str3 = "1";
    string str1 = string.Format("{0}{1}",str2,str3);
    System.Console.WriteLine(str);
    System.Console.WriteLine(str1);
    System.Console.WriteLine("is equal?: " +  (str1 == str));
    System.Console.ReadLine();
    }
}


这篇关于字符串格式化 - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:19