Click here to Skip to main content
15,898,374 members
Home / Discussions / C#
   

C#

 
AnswerRe: Interface and Implementing Class Relationship Pin
PIEBALDconsult10-Sep-10 15:07
mvePIEBALDconsult10-Sep-10 15:07 
AnswerRe: Interface and Implementing Class Relationship Pin
Luc Pattyn10-Sep-10 17:11
sitebuilderLuc Pattyn10-Sep-10 17:11 
AnswerRe: Interface and Implementing Class Relationship [modified] Pin
Paul Michalik11-Sep-10 23:04
Paul Michalik11-Sep-10 23:04 
GeneralRe: Interface and Implementing Class Relationship [modified] Pin
infinateone12-Sep-10 9:01
infinateone12-Sep-10 9:01 
GeneralRe: Interface and Implementing Class Relationship Pin
Pete O'Hanlon12-Sep-10 10:16
mvePete O'Hanlon12-Sep-10 10:16 
GeneralRe: Interface and Implementing Class Relationship Pin
infinateone12-Sep-10 10:44
infinateone12-Sep-10 10:44 
AnswerRe: Interface and Implementing Class Relationship Pin
infinateone12-Sep-10 11:07
infinateone12-Sep-10 11:07 
GeneralRe: Interface and Implementing Class Relationship Pin
Paul Michalik12-Sep-10 20:30
Paul Michalik12-Sep-10 20:30 
GeneralRe: Interface and Implementing Class Relationship Pin
infinateone13-Sep-10 4:38
infinateone13-Sep-10 4:38 
GeneralRegular Expressions Pin
Bassam Abdul-Baki10-Sep-10 3:53
professionalBassam Abdul-Baki10-Sep-10 3:53 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 3:58
sitebuilderLuc Pattyn10-Sep-10 3:58 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:09
professionalBassam Abdul-Baki10-Sep-10 4:09 
GeneralRe: Regular Expressions Pin
PIEBALDconsult10-Sep-10 4:24
mvePIEBALDconsult10-Sep-10 4:24 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:26
professionalBassam Abdul-Baki10-Sep-10 4:26 
GeneralRe: Regular Expressions Pin
PIEBALDconsult10-Sep-10 4:37
mvePIEBALDconsult10-Sep-10 4:37 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:46
professionalBassam Abdul-Baki10-Sep-10 4:46 
GeneralRe: Regular Expressions Pin
Alan Balkany10-Sep-10 4:02
Alan Balkany10-Sep-10 4:02 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:11
professionalBassam Abdul-Baki10-Sep-10 4:11 
GeneralRe: Regular Expressions Pin
Alan Balkany10-Sep-10 4:12
Alan Balkany10-Sep-10 4:12 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:15
professionalBassam Abdul-Baki10-Sep-10 4:15 
GeneralRe: Regular Expressions Pin
Alan Balkany10-Sep-10 4:22
Alan Balkany10-Sep-10 4:22 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:27
professionalBassam Abdul-Baki10-Sep-10 4:27 
GeneralRe: Regular Expressions [modified] Pin
Luc Pattyn10-Sep-10 4:34
sitebuilderLuc Pattyn10-Sep-10 4:34 
I'm afraid the switch will turn out to be expensive, and it really is unnecessary. How about:

int len=s.Length;
int i=0;
while(i<len) {
    char c=s[i++];
    if (c=='6') {
        while(i<len) {
            c=s[i++];
            if (c=='2') {
                while(i<len) {    // FIXED
                    c=s[i++];
                    if (c=='4') return true;
                }
            }
        }
    }
}
return false;


or the more structured:

string search="624x";  // FIXED
int iSearch=0;
char cSearch=search[iSearch];
foreach(char c in s) {
    if(c==cSearch) {
        cSearch=search[++iSearch];    // FIXED
        if (cSearch=='x') return true;
    }
}
return false;


BTW: none if these fulfill the requirement, as they would accept 6424 whereas the OP wants to reject that; so the state machine needs to be a tiny bit more complex.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
modified on Friday, September 10, 2010 11:03 PM

GeneralRe: Regular Expressions Pin
Alan Balkany10-Sep-10 4:39
Alan Balkany10-Sep-10 4:39 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 4:56
sitebuilderLuc Pattyn10-Sep-10 4:56 

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.