Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:56:04+00:00 2026-05-31T00:56:04+00:00

Here is my code in Objective-C for iOS that I need help converting to

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:56:05+00:00Added an answer on May 31, 2026 at 12:56 am

    I’m not familiar with Objective-C or iOS, but from Googling around it seems that NSCharacterSet is 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:

    string filter="0123456789(['!";
    string text="My phone number is (121)5551234!";
    

    If you want to see only the characters in filter, you do this:

    string filtered = new string(text.Where(c=>filter.IndexOf(c)>=0).ToArray());
    

    If you want to see only the characters not in the filter, you can do this:

    string filtered = new string(text.Where(c=>filter.IndexOf(c)<0).ToArray());
    

    Both aren’t the most efficient way to do this. If you want efficiency, use a regular expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie here (to C, objective-C, and iOS)... For this code in my AppDelegate.m, why
enter code here Hi All, I have a simple windows service application that connects
Recently I've begun to code in Objective-C for iOS 5 devices. My brand new
I'm practically new to Objective C and iOS Dev and I need to make
I am new in iOS objective c and now I build an app that
I am new to Xcode and Objective-C programming and need some help. I am
Basically, I have the following code (explained here: Objective-C Constants in Protocol ) //
I have a for loop in my Objective-C code that keeps throwing a EXC_BAD_ACCESS
For iOS developers, delegates are used almost everywhere. And seems like that we need
So I'm toying with this code here, and the main objective is to update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.