array of char to string in c#

2020-05-08 07:21发布

I have a string that looks like a phone number. I'm using a lambda to extract an array of char. Then I want to convert this array into a string. This is what I have:

PhoneCandidate = "(123)-321-1234"; //this is just an example of what it could look like
var p = PhoneCandidate.Where(c => char.IsDigit(c)).ToArray();

string PhoneNumber = p.toString();

However, when I run this code, the variable PhoneNumber becomes just "System.Char[]" instead of the values inside the array.

What do I need to change?

Thanks.

标签: c#
7条回答
霸刀☆藐视天下
2楼-- · 2020-05-08 07:58
string phone = new string(p);

查看更多
登录 后发表回答