次のコードは正常にコンパイル:デバッガで新しい文字列を使用できないのはなぜですか?
string foo = new string(new char[] { 'b', 'a', 'r' });
ウォッチウィンドウまたはイミディエイトウィンドウに貼り付ける場合は、次のコードが評価されるように失敗します。
new string(new char[] { 'b', 'a', 'r' });
エラーメッセージは次のとおりです。
'new string(new char[] { 'b', 'a', 'r' })' threw an exception of type 'System.ArgumentException'
base {System.SystemException}: {"Only NewString function evaluation can create a new string."}
Message: "Only NewString function evaluation can create a new string."
ParamName: null
なぜこれが起こりますか?
を参照してくださいに結果
string
オブジェクトを転送することによってstring
コンストラクタにこのブログの記事を呼び出しますVisual StudioでVB.Netで2010年に、この例外は表示されません注意してください](http://dotnetdust.blogspot.com/2009/03/string-construtor-stringchar-value.html)。 – cdhowieこれはVS 2015で「固定」となっていますが、Roslynを使用しているため推測しています。 –