Click here to Skip to main content
16,013,082 members
Home / Discussions / C#
   

C#

 
GeneralRe: Something better than Switch Case Pin
Muammar©11-Feb-09 10:28
Muammar©11-Feb-09 10:28 
AnswerRe: Something better than Switch Case Pin
akidan11-Feb-09 11:04
akidan11-Feb-09 11:04 
GeneralRe: Something better than Switch Case Pin
Pete O'Hanlon11-Feb-09 11:07
mvePete O'Hanlon11-Feb-09 11:07 
GeneralRe: Something better than Switch Case Pin
akidan11-Feb-09 11:11
akidan11-Feb-09 11:11 
GeneralRe: Something better than Switch Case Pin
Muammar©11-Feb-09 22:16
Muammar©11-Feb-09 22:16 
GeneralRe: Something better than Switch Case Pin
akidan12-Feb-09 3:10
akidan12-Feb-09 3:10 
AnswerRe: Something better than Switch Case Pin
Deresen11-Feb-09 10:45
Deresen11-Feb-09 10:45 
AnswerRe: Something better than Switch Case Pin
Pete O'Hanlon11-Feb-09 11:06
mvePete O'Hanlon11-Feb-09 11:06 
You could always use a Dictionary with an enumeration and a Action to use. For instance, you could have an enumeration that closed a window like this:
public enum Operation 
{
  Close,
  Save,
}
public void Action(Operation action)
{
  if (_dictionary.ContainsKey(action))
  {
    _dictionary[action]();
  }
}
public void Register(Operation operation, Action action)
{
  _dictionary.Add(operation, action);
}
Then, you can add your implementation like this:
Register(Operation.Close, delegate(){ this.Close(); });
As you can see, calling this method removes the need for a switch altogether.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

My blog | My articles | MoXAML PowerToys



GeneralRe: Something better than Switch Case Pin
led mike11-Feb-09 11:29
led mike11-Feb-09 11:29 
GeneralRe: Something better than Switch Case Pin
akidan11-Feb-09 11:31
akidan11-Feb-09 11:31 
GeneralRe: Something better than Switch Case Pin
Muammar©11-Feb-09 22:27
Muammar©11-Feb-09 22:27 
GeneralRe: Something better than Switch Case Pin
J4amieC11-Feb-09 23:22
J4amieC11-Feb-09 23:22 
GeneralRe: Something better than Switch Case Pin
Muammar©12-Feb-09 0:44
Muammar©12-Feb-09 0:44 
AnswerRe: Something better than Switch Case Pin
Christian Graus11-Feb-09 11:37
protectorChristian Graus11-Feb-09 11:37 
QuestionRemove empty textbox spaces Pin
ferronrsmith11-Feb-09 9:35
ferronrsmith11-Feb-09 9:35 
GeneralRe: Remove empty textbox spaces Pin
Lodeclaw11-Feb-09 9:51
Lodeclaw11-Feb-09 9:51 
GeneralRe: Remove empty textbox spaces Pin
ferronrsmith11-Feb-09 10:19
ferronrsmith11-Feb-09 10:19 
AnswerRe: Remove empty textbox spaces [modified] Pin
Lodeclaw11-Feb-09 10:27
Lodeclaw11-Feb-09 10:27 
GeneralRe: Remove empty textbox spaces Pin
Deresen11-Feb-09 10:41
Deresen11-Feb-09 10:41 
GeneralRe: Remove empty textbox spaces Pin
ferronrsmith11-Feb-09 11:35
ferronrsmith11-Feb-09 11:35 
GeneralRe: Remove empty textbox spaces Pin
Lodeclaw11-Feb-09 11:49
Lodeclaw11-Feb-09 11:49 
GeneralRe: Remove empty textbox spaces Pin
ferronrsmith11-Feb-09 11:52
ferronrsmith11-Feb-09 11:52 
AnswerRe: Remove empty textbox spaces [modified] Pin
Lodeclaw11-Feb-09 11:55
Lodeclaw11-Feb-09 11:55 
GeneralRe: Remove empty textbox spaces Pin
ferronrsmith11-Feb-09 12:02
ferronrsmith11-Feb-09 12:02 
GeneralRe: Remove empty textbox spaces Pin
Lodeclaw11-Feb-09 12:14
Lodeclaw11-Feb-09 12:14 

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.