switch

C# switch statement

Should I throw NotImplementedException() on default: if I have cases for all possible enum types? ...

Why doesn't C# switch statement allow using typeof/GetType() ?

As in this example: switch ( myObj.GetType ( ) ) { case typeof(MyObject): Console.WriteLine ( "MyObject is here" ); break; } ...

Switch Statement with Strings C#

I need to write something that will get the start-up arguments and then do something for those start-up args, and I was thinking that switch would be good but it only accepts for ints and it has to be for a string This isn't the actual code but I want to know how to make something like this work namespace Simtho { class Program ...

What is the best way to write a C# application "kill switch"?

I need to write a "kill switch" into my C# application for licensing/billing purposes. What is the best way to do that? The requirements are as follows (its actually 2 kill switches): 1 - "passive kill switch" - If a particular user does not log into the application in X days then the application stops working. 2 - "active kill switch...

Code smell in this switch statement?

I'm wondering where a switch statement of this style should be changed to an if else statement. switch (foo) // foo is an enumerated type { case barOne: if (blahOne) { DoFunction(//parameters specific to barOne); break; } case barTwo: if (blahTwo) { DoFun...

C# switch/break

It appears I need to use a break in each case block in my switch statement using C#. I can see the reason for this in other languages where you can fall through to the next case statement. Is it possible for case blocks to fall through to other case blocks? Thanks very much, really appreciated! ...

C# Switch Statement refactoring

The purpose of the code below is to determine if a particular date qualifies as a "weekend" i.e after 12:00 PM on Thursday, minimum 2 days and before Monday 12:00 PM Is there a better way? If-Else turns ugly and the Strategy pattern is way too much work for this. public bool ValidateWeekend(DateTime pickupDate, DateTime dropoffDate) ...

How to relocate copied svn folder

Hey all, i copied an existing svn folder (a) to a new folder b and want to also switch the repository url. Its still pointing to a repo. i try svn switch --relocate but only get: svn: Relocate can only change the repository part of an URL What is the right way to do this task? Thanks for your help! ...

The old switcheroo (switch position in file)

Hi All, I would really appreciate if somebody could help me/offer advice on this. I have a file, probably about 50000 lines long, these files are generated on a weekly basis. each line is identical in terms of type of content. original file: address^name^notes but i need to perform a switch. i need to be able to switch (on each and...

Switching a view

Hello! I have a problem with switching views in an iPhone application. I have the source code of "Beginning iPhone 3 Development" (http://books.google.com/books?id=TcP2bgESYfgC&printsec=frontcover&dq=beginning+iphone+3+development#v=onepage&q=beginning%20iphone%203%20development&f=false) - chapter 6 - Multiview Applicati...

Method not being called in switch statement

Edit: Works perfectly in debugger now, but block doesn't rotate at all when run normally.. I'm having a problem that I've run through the debugger a ton and have narrowed it down to this. I've got a block on screen that comes down in the middle and rotates. The image of the block obviously changes depends on the rotation, and this is d...

What is the overhead involved in a mode switch

Hi Many a times i read/hear the argument that making a lot of system calls etc would be inefficient since the application make a mode switch i.e goes from user mode to kernel mode and after executing the system call starts executing in the user mode by making a mode switch again. My question is what is the overhead of a mode switch ? D...

Status "S" in Subversion

At some point all files in my working copy got marked with "S" symbol as shown below: $ svn st M S AclController.php S InstallationController.php S CustomerController.php S RedirController.php S IndexController.php S LoginController.php S OrderController.php S ProductController.php ...

WPF PreviewKey fails on application switch

I have a WPF application that makes use of the PreviewKeyUp function to handle keystrokes before they might otherwise be dealt with. It works fine, but often (not always) if I switch to another windows application and then back, it just stops working. If I interact with anything on the form that can accept focus (say a button, or a tex...

IPhone - ViewSwitch Problem

HI everybody, I've got a problem with the view-switch. When first switching into the landscapeview everything seems to be ok, but switching back into the portraitview my view is scaled in the wrong way. so the left picture shows how it should look like (and how it looks before the switch), and the right one shows how it actually looks a...

c++ multiple enums in one function argument using bitwise or "|"

Hi, I recently came across some functions where you can pass multiple enums like this: myFunction(One | Two); Since I think this is a really elegant way I tried to implement something like that myself: void myFunction(int _a){ switch(_a){ case One: cout<<"!!!!"<<endl; break; case Two: cout<<"?????"<<e...

Transfer of entire contents including white space of non-volatile storage on switch to a server over ssh

This is a feature request for our networking switch where a customer wants complete binary dump of the entire contents (including white space) of all the non-volatile storage we have on our equipment (like compact flash/eeprom) to a server over a ssh v2 connection. What is the best way to do this ? ...

Tortoisesvn creating a branch and switch

This might be a dumb question but I'm unable to understand: When we create a new branch, why do we need to 'switch'? What does this 'switch' exactly do? Can't I use the whole repository as I was using earlier without bothering about switch? ...

c# switch problem

I'm new to programming and having a problem with the following code: private string alphaCoords(Int32 x) { char alphaChar; switch (x) { case 0: alphaChar = 'A'; break; case 1: alphaChar = 'B'; break; case 2: alphaChar = 'C'; break; case 3: alphaChar = 'D'; ...

Dynamic Titles question

How would I make it possible to have dynamic(i think thats the word) titles with this setup? For example when I'm viewing a profile I want it to say Viewing profile of USERNAME' inside <title>. How could I make this possible without putting the html top on each indivudual page? Thanks a lot. and please dont start talking about mvc's, i...