Click here to Skip to main content
16,008,490 members
Home / Discussions / C#
   

C#

 
AnswerRe: Bioinformatics / DNA / Protein analysis - in C# Pin
Paul Conrad30-Nov-07 15:18
professionalPaul Conrad30-Nov-07 15:18 
GeneralRe: Bioinformatics / DNA / Protein analysis - in C# Pin
mg123430-Nov-07 19:17
mg123430-Nov-07 19:17 
Question[Message Deleted] Pin
gubba30-Nov-07 13:44
gubba30-Nov-07 13:44 
AnswerRe: setting timer Pin
Christian Graus30-Nov-07 15:00
protectorChristian Graus30-Nov-07 15:00 
General[Message Deleted] Pin
gubba30-Nov-07 15:15
gubba30-Nov-07 15:15 
GeneralRe: setting timer Pin
Paul Conrad30-Nov-07 15:19
professionalPaul Conrad30-Nov-07 15:19 
QuestionChanging MDB Tool Generated Dataset Source Pin
Reanalyse30-Nov-07 12:55
Reanalyse30-Nov-07 12:55 
QuestionQuestion about Base64 code example Pin
CCMint30-Nov-07 12:50
CCMint30-Nov-07 12:50 
Hi,

I am reading the C# cookbook and came across the "encoding binary data as base64" section. They don't explain how it works so I have a question I hope I can get cleared up.

Here is the snippet:

<br />
public string Base64EncodeBytes(byte[] inputBytes)<br />
{<br />
  long arrayLength = (long)(4.0d * inputBytes.Length / 3.0d);<br />
  if((arrayLength % 4) != 0)<br />
  {<br />
    arrayLength += 4 - (arrayLength % 4);<br />
  }<br />
<br />
  char[] theEncodedCharArray = new char[arrayLength];<br />
  Convert.ToBase64CharArray(inputBytes, 0, inputBytes.Length, theEncodedCharArray, 0);<br />
<br />
  return (new string(theEncodedCharArray));<br />
}<br />


long arrayLength = (long)(4.0d * inputBytes.Length / 3.0d);
they say that the above line is needed to change each 3 byte sequence into a 4 byte sequence.
why does it have to be converted? I thought that when converting to base64 you use 3 bytes at a time.

thanks
QuestionLooks like database connection is giving an error that the object is null Pin
T4AMD30-Nov-07 11:04
T4AMD30-Nov-07 11:04 
AnswerRe: Looks like database connection is giving an error that the object is null Pin
Ian Shlasko30-Nov-07 11:12
Ian Shlasko30-Nov-07 11:12 
GeneralRe: Looks like database connection is giving an error that the object is null Pin
T4AMD30-Nov-07 11:39
T4AMD30-Nov-07 11:39 
GeneralRe: Looks like database connection is giving an error that the object is null Pin
Pete O'Hanlon30-Nov-07 11:50
mvePete O'Hanlon30-Nov-07 11:50 
AnswerRe: Looks like database connection is giving an error that the object is null Pin
Pete O'Hanlon30-Nov-07 11:35
mvePete O'Hanlon30-Nov-07 11:35 
QuestionNeed c# programmer Pin
AndreasSweden30-Nov-07 10:19
AndreasSweden30-Nov-07 10:19 
AnswerRe: Need c# programmer Pin
Paul Conrad30-Nov-07 10:56
professionalPaul Conrad30-Nov-07 10:56 
QuestionHow can I clear a buffer? Pin
daavena30-Nov-07 9:37
daavena30-Nov-07 9:37 
AnswerRe: How can I clear a buffer? Pin
Dan Neely30-Nov-07 9:45
Dan Neely30-Nov-07 9:45 
GeneralRe: How can I clear a buffer? Pin
daavena30-Nov-07 10:10
daavena30-Nov-07 10:10 
GeneralRe: How can I clear a buffer? Pin
Ian Shlasko30-Nov-07 11:08
Ian Shlasko30-Nov-07 11:08 
GeneralRe: How can I clear a buffer? Pin
daavena1-Dec-07 1:40
daavena1-Dec-07 1:40 
AnswerRe: How can I clear a buffer? Pin
Anthony Mushrow30-Nov-07 10:00
professionalAnthony Mushrow30-Nov-07 10:00 
AnswerRe: How can I clear a buffer? Pin
ovrgarriga30-Nov-07 10:49
ovrgarriga30-Nov-07 10:49 
GeneralRe: How can I clear a buffer? Pin
daavena30-Nov-07 12:40
daavena30-Nov-07 12:40 
GeneralRe: How can I clear a buffer? Pin
ovrgarriga1-Dec-07 1:16
ovrgarriga1-Dec-07 1:16 
GeneralRe: How can I clear a buffer? Pin
daavena1-Dec-07 1:49
daavena1-Dec-07 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.