Click here to Skip to main content
15,881,801 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using Reflection Pin
Mycroft Holmes28-Nov-17 23:02
professionalMycroft Holmes28-Nov-17 23:02 
GeneralRe: Using Reflection Pin
User 740747028-Nov-17 23:37
User 740747028-Nov-17 23:37 
AnswerRe: Using Reflection Pin
BillWoodruff30-Nov-17 0:35
professionalBillWoodruff30-Nov-17 0:35 
GeneralRe: Using Reflection Pin
Mycroft Holmes30-Nov-17 12:01
professionalMycroft Holmes30-Nov-17 12:01 
GeneralRe: Using Reflection Pin
BillWoodruff30-Nov-17 21:48
professionalBillWoodruff30-Nov-17 21:48 
QuestionI am trying to create and write to a file using one boolean bit at a time. Pin
computerpublic28-Nov-17 13:17
computerpublic28-Nov-17 13:17 
GeneralRe: I am trying to create and write to a file using one boolean bit at a time. Pin
PIEBALDconsult28-Nov-17 14:21
mvePIEBALDconsult28-Nov-17 14:21 
AnswerRe: I am trying to create and write to a file using one boolean bit at a time. Pin
Sascha Lefèvre28-Nov-17 14:52
professionalSascha Lefèvre28-Nov-17 14:52 
Oh dear Big Grin | :-D

- The smallest unit of "writable data" is a byte.

- Drop that goto (and please don't use it ever again, for anything). Instead: Toggling a boolean variable is as easy as this:
C#
tif = !tif;

- Doesn't help a lot here though because the change will not reflect in buffer. After you create buffer it keeps its value forever.

- You're using the third parameter of the Stream.Write-method wrongly - at least judging from your described intent. It's supposed to be the amount of bytes from buffer, starting at position 0, that should be written into the file stream. But buffer is only 1 byte long and bits says there should be 32 bytes. That's where you are "outside of the array bounds".

- Your while-loop will run forever because bits will be > 0 forever.

You should start using the debugger. Place a breakpoint at the start of your method (first line or opening brace) by placing the cursor there and pressing F9. Then start your program in debug mode by pressing F5. Then step over the execution line-by-line by pressing F10* while you inspect the values of your variables by hovering with the mouse cursor over it. Compare the values you expect with their actual values and when there's a difference try to find out, why.

*: Take a look at further ways of stepping through your code while debugging: In the Debug-Menu and/or the Debugging-Toolbar (and the Debugger-documentation).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

AnswerRe: I am trying to create and write to a file using one boolean bit at a time. Pin
Gerry Schmitz29-Nov-17 4:59
mveGerry Schmitz29-Nov-17 4:59 
AnswerRe: I am trying to create and write to a file using one boolean bit at a time. Pin
________________2-Dec-17 23:37
________________2-Dec-17 23:37 
QuestionActive Directory Code Not Returning All Objects Pin
Kevin Marois28-Nov-17 12:37
professionalKevin Marois28-Nov-17 12:37 
AnswerRe: Active Directory Code Not Returning All Objects Pin
Richard Deeming30-Nov-17 8:04
mveRichard Deeming30-Nov-17 8:04 
QuestionHow to use RegEx for AlphaNumeric expressions Pin
Member 1348136128-Nov-17 8:56
Member 1348136128-Nov-17 8:56 
AnswerRe: How to use RegEx for AlphaNumeric expressions Pin
Dave Kreskowiak28-Nov-17 10:49
mveDave Kreskowiak28-Nov-17 10:49 
AnswerRe: How to use RegEx for AlphaNumeric expressions Pin
Dave Kreskowiak28-Nov-17 10:52
mveDave Kreskowiak28-Nov-17 10:52 
AnswerRe: How to use RegEx for AlphaNumeric expressions Pin
Gerry Schmitz29-Nov-17 4:52
mveGerry Schmitz29-Nov-17 4:52 
QuestionEntity FrameWork Question Pin
Kevin Marois28-Nov-17 6:08
professionalKevin Marois28-Nov-17 6:08 
AnswerRe: Entity FrameWork Question Pin
Richard MacCutchan28-Nov-17 6:11
mveRichard MacCutchan28-Nov-17 6:11 
GeneralRe: Entity FrameWork Question Pin
Kevin Marois28-Nov-17 6:15
professionalKevin Marois28-Nov-17 6:15 
GeneralRe: Entity FrameWork Question Pin
Richard MacCutchan28-Nov-17 6:18
mveRichard MacCutchan28-Nov-17 6:18 
GeneralRe: Entity FrameWork Question Pin
Kevin Marois28-Nov-17 6:19
professionalKevin Marois28-Nov-17 6:19 
QuestionParameterized Command Not Adding To DB Pin
MsJane27-Nov-17 8:21
MsJane27-Nov-17 8:21 
AnswerRe: Parameterized Command Not Adding To DB Pin
Sascha Lefèvre27-Nov-17 8:54
professionalSascha Lefèvre27-Nov-17 8:54 
AnswerRe: Parameterized Command Not Adding To DB Pin
Richard MacCutchan27-Nov-17 22:06
mveRichard MacCutchan27-Nov-17 22:06 
AnswerRe: Parameterized Command Not Adding To DB Pin
MsJane30-Nov-17 5:13
MsJane30-Nov-17 5:13 

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.