Jason Jason - 1 year ago 81
C# Question

Code improvement with easy

I made beeps using

extern public static void Beep(int freq, int dur);

// and

Beep(2222, 55);
Beep(3333, 55);

I have planted this code ( Beep( freq, dura) ) almost a hundread times here and there(with various frequency, duration and times).

Now, I want to switch between Sound and Mute programtically.

I could do it with something like

if ( my_Flag )
Beep( 2222, 55);
Beep( 3333, 55);

It should be tedious work to do.
Is there any better ideas ?


Answer Source

If everything is defined as Beep(x,y) method, You can write Your own method and then Refactor->Rename all methods to MyBeep(x,y) for example.

public void MyBeep(int freq, int dur)
        Beep(freq, dur);

How to refactor->rename on YT.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download