我想使用回車/換行符組合(Chr(13)+ Chr(10))。 我使用Microsoft.VisualBasic命名空間,但我得到的錯誤system.linq.strings由於其保護級別再次無法訪問
system.linq.strings不可訪問,因爲它保護
string Wrap = Strings.Chr(13) + Strings.Chr(10);
我想使用回車/換行符組合(Chr(13)+ Chr(10))。 我使用Microsoft.VisualBasic命名空間,但我得到的錯誤system.linq.strings由於其保護級別再次無法訪問
system.linq.strings不可訪問,因爲它保護
string Wrap = Strings.Chr(13) + Strings.Chr(10);
在C#中這樣做的慣用方式是string Wrap = "\r\n";
。在這種情況下,雖然,我只想把它放在網上,像這樣:
MessageBox.Show("Encryption Complete\r\n\r\nTotal bytes processed = "
+ lngBytesProcessed, // note: no need to convert to string
"Done",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
非常感謝。它的作品非常好。 – suleimankurawa
編譯器無法找出哪些Strings
你想使用的課程。你可以明確寫出Microsoft.VisualBasic.Strings.Chr(13)
來幫助它。但在這種情況下,您應該使用Environment.NewLine
代替。無論您的操作系統如何,它都應該爲您提供正確的字符組合。
在C#中,您應該使用"\r\n"
或Environment.NewLine
。
您收到此錯誤,因爲該系統試圖致電「字符串」方法,即在「Microsoft.VisualBasic程序」。出於某種原因,它沒有找到它,它試圖調用「System.Linq」上的方法。在你刪除System.Linq,如果你沒有使用任何集合或做任何與Linq
\ r \ n是更簡潔和重點。嘗試
const string wrap = @"\r\n";
代替
「又」?那麼在我假設之前你已經解決了這個問題? –
[system.linq.strings可能由於其保護級別而無法訪問](http://stackoverflow.com/questions/8527156/system-linq-strings-is-inaccessible-due-to-its-protection-level ) –
如果您使用C#編程,爲什麼使用「Microsoft.VisualBasic」命名空間? –