&tag(CSharp/文字列);
// Avoid getting confused by interning
object x = new StringBuilder("hello").ToString();
object y = new StringBuilder("hello").ToString();
if (x.Equals(y)) // Yes
// 参照の比較が行われる
if (x == y) // No
string xs = (string) x;
string ys = (string) y;
// ==(string, string)が呼ばれる
if (xs == ys) // Yes{
※参考リンク
String.Format(format, arg1, arg2...)を使う。
String.Format("xの値は{0}です。yの値は{1}です。", x, y);
public static string ToCsv<T>(this IEnumerable<T> source)
{
if (source == null) throw new ArgumentNullException("source");
return string.Join(",", source.Select(s => s.ToString()).ToArray());
}