Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
try to use the following method to pass the format to my phone number,butis not work
can anybody explain

the error i have is

'string' does not contain a definition for 'substring' and no extension method 'substring' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

the model
C#
public class ViewModel
   {

      
      

       private string formatPhoneNumber(string phone)
       {
        

           //should return (123)456-7890
           return string.Format("({0})-{1}-{2}");
       }

   }
Posted
Updated 17-Oct-12 19:19pm
v4
Comments
Sergey Alexandrovich Kryukov 18-Oct-12 0:04am    
What is broken? MSDN? Google? Bing?..
--SA
Sushil Mate 18-Oct-12 0:16am    
ohh come on.. spelling mistake? huh..
Sergey Alexandrovich Kryukov 18-Oct-12 13:50pm    
Spelling is mere politeness when writing to people. To a compiler... poor spelling is just a waste of CPU cycles...
--SA

1 solution

Something is fundamentally wrong with your approach to work in general. Was it so difficult to look at the MSDN help page and see the right spelling? Well, take a look now:
http://msdn.microsoft.com/en-us/library/system.string.substring.aspx[^].

Please, no offense: what you really need to learn is this: Microsoft Q209354.

—SA
 
Share this answer
 
Comments
Sushil Mate 18-Oct-12 0:27am    
quite offensive link there :)
I don't know, day by day OP's level decreasing... one day you will wake up
& you ll find something weird like this..god only knows what they will ask..
Sergey Alexandrovich Kryukov 18-Oct-12 0:36am    
Not for the first time... really deserved, anyway.
Yes, this is sad. It makes less and less sense. But some question really deserve the effort. Maybe, we should delete 99%, to support reputation of the forum.

Thank you,
--SA
[no name] 18-Oct-12 1:37am    
Agreed with Kryukov.
People are expecting that we will do google for them. We should vote/downvote each question to maintain the reputation of the forum.
Sergey Alexandrovich Kryukov 18-Oct-12 13:48pm    
Thank you for your understanding and support. I also think that the absolute majority of posts should be eventually deleted when not answered and the inquirer shows no collaborative activity during certain period of time. An inquirer should be given a chance, but many don't bother replying if members ask to clarify question. Such posts have only negative impact: people just searching of available answers get more an more trash instead of answers. This is about reputation of the forum, yes.

I advise all members to actively remove hopeless question posts, their own and someone's else. The mistake here won't be vital: if OP really cares, she/he will post again, in improved way.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900