Curious what using directory I am missing

2505 views c#

Hey everyone thanks for taking the time to answer

When I bring in the following code

var inputString = "xxxxx";

var code = Convert.ToBase64String((new ASCIIEncoding()).GetBytes(inputString)).ToCharArray().Select(x => String.Format("{0:X}", (int)x)).Aggregate(new StringBuilder(), (x, y) => x.Append(y)).ToString();

ToCharArray().Select gets underlined with the following error message:

Char[] does not contain a definition for a 'Select' and no extension method 'Select' accepting a first arguement of type char[] could be found (are you missing a directory or assembly reference).

I pulled this code from an older post on here about disguising usernames behind a tobase64 string. I know its not encryption, but it will get the point across to those I need it to.

answered question

Reread the error message carefully, It says nothing about a directory

1 Answer


You are not missing a directory but probably a reference to Linq. Select() is an extension method defined in System.Linq, so probably you need to add:

using System.Linq;

posted this

Have an answer?


Please login first before posting an answer.