suleimankurawa
suleimankurawa

Reputation: 51

system.linq.strings is inaccessible due to its protection level again

I want to use the carriage-return/linefeed character combination (Chr(13)+Chr(10)). I am using the Microsoft.Visualbasic namespace but I am getting the error

system.linq.strings is inaccessible due to its protection

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

Upvotes: 0

Views: 2866

Answers (5)

Yuriy Faktorovich
Yuriy Faktorovich

Reputation: 68667

The compiler can't figure out which Strings class you'd like to use. You can explicitly write out Microsoft.VisualBasic.Strings.Chr(13) to help it along. But in this case you should use the Environment.NewLine instead. It should get you the correct character combination regardless of your operating system.

Upvotes: 4

Jason Meckley
Jason Meckley

Reputation: 7591

\r\n is much more concise and to the point. try

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

instead

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 837946

In C# you should use "\r\n" or Environment.NewLine.

Upvotes: 3

MethodMan
MethodMan

Reputation: 18843

You are getting this error, because the system is trying to call the "String" method that is in "Microsoft.VisualBasic". For some reason it is not finding it and it is trying to call the method on "System.Linq". in your remove System.Linq if you are not using any Collections or doing anything with Linq

Upvotes: -1

Gabe
Gabe

Reputation: 86698

The idiomatic way to do this in C# is string Wrap = "\r\n";. In this situation, though, I would simply put it in-line, like this:

MessageBox.Show("Encryption Complete\r\n\r\nTotal bytes processed = "
                + lngBytesProcessed, // note: no need to convert to string
                "Done",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);

Upvotes: 0

Related Questions