Here is my code in Objective-C for iOS that I need help converting to C#:
NSString kLegal = @"0123456789(['!";
NSString character = @"(";
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:kLegal] invertedSet];
NSString *filtered = [[character componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
I’m familiar with C# and .NET but really don’t have a clue where to begin here. Thanks!
I’m not familiar with Objective-C or iOS, but from Googling around it seems that
NSCharacterSetis used to filter characters – either specifying the characters you want or those you don’t want.You can do that in C# in several ways. Here’s one:
If you want to see only the characters in filter, you do this:
If you want to see only the characters not in the filter, you can do this:
Both aren’t the most efficient way to do this. If you want efficiency, use a regular expression.