I assume you are a beginner, and this is kind of "homework" project?
I can't resist to give you a tip learned in painfull lessons: the most important thing about programming is: inventing names and remembering them. those names are the symbols in your head for the problem domain. So: give your variables always meaningful names (aaa, xxx is not so good ;-) and using
as variable name is even worse - because it's a keyword! (I don't tell you now how to use keywords as names - it's possible - but you should never do it!)
To your problem:
I can't figure out what your code is trying to achive. Why are you adding
+ counter variable
to a string? So forgive me if I got you wrong, I just present a solution for what I think you want:
string strPassword = "ashwani";
byte abyPasswordBytes = Encoding.ASCII.GetBytes(strPassword);
string strAllByteValues = String.Empty;
foreach (byte by in abyPasswordBytes)
strAllByteValues += by.ToString() + " ";
So you see: after calling
you already have the individual bytes for your string - it seems you just got confused how to use them later...
So, good luck with your project and kind regards