2011-12-16 35 views
0

我想使用回車/換行符組合(Chr(13)+ Chr(10))。 我使用Microsoft.VisualBasic命名空間,但我得到的錯誤system.linq.strings由於其保護級別再次無法訪問

system.linq.strings不可訪問,因爲它保護

string Wrap = Strings.Chr(13) + Strings.Chr(10); 
+0

「又」?那麼在我假設之前你已經解決了這個問題? –

+0

[system.linq.strings可能由於其保護級別而無法訪問](http://stackoverflow.com/questions/8527156/system-linq-strings-is-inaccessible-due-to-its-protection-level ) –

+2

如果您使用C#編程,爲什麼使用「Microsoft.VisualBasic」命名空間? –

回答

0

在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); 
+0

非常感謝。它的作品非常好。 – suleimankurawa

4

編譯器無法找出哪些Strings你想使用的課程。你可以明確寫出Microsoft.VisualBasic.Strings.Chr(13)來幫助它。但在這種情況下,您應該使用Environment.NewLine代替。無論您的操作系統如何,它都應該爲您提供正確的字符組合。

-1

您收到此錯誤,因爲該系統試圖致電「字符串」方法,即在「Microsoft.VisualBasic程序」。出於某種原因,它沒有找到它,它試圖調用「System.Linq」上的方法。在你刪除System.Linq,如果你沒有使用任何集合或做任何與Linq

0

\ r \ n是更簡潔和重點。嘗試

const string wrap = @"\r\n"; 

代替

相關問題