Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: Compress and decompress string between java and c# Pin
Hossein Khalaj8-Dec-11 7:40
Hossein Khalaj8-Dec-11 7:40 
AnswerRe: Compress and decompress string between java and c# Pin
Luc Pattyn8-Dec-11 8:39
sitebuilderLuc Pattyn8-Dec-11 8:39 
GeneralRe: Compress and decompress string between java and c# Pin
Hossein Khalaj8-Dec-11 8:48
Hossein Khalaj8-Dec-11 8:48 
AnswerRe: Compress and decompress string between java and c# Pin
Luc Pattyn8-Dec-11 9:06
sitebuilderLuc Pattyn8-Dec-11 9:06 
GeneralRe: Compress and decompress string between java and c# Pin
Hossein Khalaj8-Dec-11 9:10
Hossein Khalaj8-Dec-11 9:10 
QuestionClass to toggle a bool when it goes out of scope Pin
__John_8-Dec-11 3:58
__John_8-Dec-11 3:58 
AnswerRe: Class to toggle a bool when it goes out of scope Pin
PIEBALDconsult8-Dec-11 4:12
mvePIEBALDconsult8-Dec-11 4:12 
AnswerRe: Class to toggle a bool when it goes out of scope Pin
__John_8-Dec-11 5:03
__John_8-Dec-11 5:03 
Ok, I have made some progress on this.

I think I can do it using "using" as follows

C#
MyClass::Foo()
{
    using (ToggleBool tb = new ToggleBool(ref _baseControl._bReadingLog))
    {
        // do somthing with multiple returns
    }
}


The problem I am now having is with my ToggleBool class...

C#
class ToggleBool : IDisposable
    {
        public ToggleBool(ref bool bVal)
        {
            _bVal = bVal;
        }

        public void Dispose()
        {
            _bVal = !(bool)_bVal;

            GC.SuppressFinalize(this);
        }

        private object _bVal;
    }


It is not toggling the origional bool ref that is passed to its constructor. Is my ref, somewhere along the line becoming a value?
Or is it some other error?

Thanks - John.
GeneralRe: Class to toggle a bool when it goes out of scope Pin
harold aptroot8-Dec-11 5:21
harold aptroot8-Dec-11 5:21 
GeneralRe: Class to toggle a bool when it goes out of scope Pin
__John_11-Dec-11 22:15
__John_11-Dec-11 22:15 
GeneralRe: Class to toggle a bool when it goes out of scope Pin
harold aptroot11-Dec-11 22:34
harold aptroot11-Dec-11 22:34 
GeneralRe: Class to toggle a bool when it goes out of scope Pin
__John_12-Dec-11 0:28
__John_12-Dec-11 0:28 
GeneralRe: Class to toggle a bool when it goes out of scope Pin
BobJanova8-Dec-11 5:45
BobJanova8-Dec-11 5:45 
QuestionDisplay HTML data as a webpage in C# control Pin
sarang_k8-Dec-11 1:48
sarang_k8-Dec-11 1:48 
AnswerRe: Display HTML data as a webpage in C# control Pin
Ravi Bhavnani8-Dec-11 2:07
professionalRavi Bhavnani8-Dec-11 2:07 
QuestionRe: Display HTML data as a webpage in C# control Pin
sarang_k11-Dec-11 19:16
sarang_k11-Dec-11 19:16 
QuestionWebBrowser : how to show popup window? Pin
Sunil P V8-Dec-11 0:49
Sunil P V8-Dec-11 0:49 
Questionconvert wsdl inline schema imports into xsd Pin
Agweet7-Dec-11 19:50
Agweet7-Dec-11 19:50 
QuestionAdd context menu in windows explorer in c# 2010 Pin
iamdking7-Dec-11 19:19
iamdking7-Dec-11 19:19 
AnswerRe: Add context menu in windows explorer in c# 2010 Pin
Richard MacCutchan7-Dec-11 22:02
mveRichard MacCutchan7-Dec-11 22:02 
GeneralRe: Add context menu in windows explorer in c# 2010 Pin
iamdking7-Dec-11 22:50
iamdking7-Dec-11 22:50 
QuestionHow to make different color in different trangle in WPF Pin
derek09197-Dec-11 14:07
derek09197-Dec-11 14:07 
AnswerRe: How to make different color in different trangle in WPF Pin
derek09197-Dec-11 22:58
derek09197-Dec-11 22:58 
GeneralRe: How to make different color in different trangle in WPF Pin
Pete O'Hanlon7-Dec-11 23:15
mvePete O'Hanlon7-Dec-11 23:15 
GeneralRe: How to make different color in different trangle in WPF Pin
derek09198-Dec-11 2:45
derek09198-Dec-11 2:45 

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.