1

I want to return a List from the following code:

private List<string> tokenizer(string x)
.........
 ..........
i has done thank you

I tried to use

.ToList();

but it didn't work. can anyone help? thanks.

8
  • 4
    String.Join returns a string. What are you trying to do? If you simply want a list, just remove the string.join and replace .ToArrray with .ToList Commented May 9, 2012 at 15:11
  • string.Join creates a single string. Commented May 9, 2012 at 15:11
  • What is the return type of the method that this is in? Commented May 9, 2012 at 15:11
  • A list of what? String.Join concats a list of strings into a single string, you want to not do that? Commented May 9, 2012 at 15:11
  • 3
    "i want return the string after remove the noisy text into List<string>" I understand each of those words individually. Commented May 9, 2012 at 15:15

2 Answers 2

2

I will take a shot at this. Is this what your after?

var list = from s in Regex.Split(sb.ToString(), "([ \\t{}()\n])") 
             where s.Length > 3 && !exclude.IsMatch(s) 
             select s.Replace("!‌", "@")).ToList()

Then you can return it:

return list;

If this isn't what you are trying to do please provide more details.

Sign up to request clarification or add additional context in comments.

Comments

1

Is this what you want?

return new List<String>(
    from s in Regex.Split(sb.ToString(), "([ \\t{}()\n])")
    where s.Length > 3 && !exclude.IsMatch(s)
    select s.Replace("!‌", "@"));

Not sure why you're joining the strings together if you want the list of cleaned up text.

1 Comment

I see you now include a method signature, what is it that my or @BaliC 's answer that isn't working for you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.