Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
how to split string single Quote value
 
Example The Value 'sd' is not valid value
 
i required like
 
The Value --1 value
'sd' ---2nd value
is not valid value---3rd value
how to do
Posted 4-Oct-12 2:19am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can use the native Split method.
 
http://msdn.microsoft.com/en-us/library/b873y76a.aspx[^]
 
string example = "The Value 'sd' is not valid value";
 
string[] returnValues = example.split('\'');
  Permalink  
Comments
Abhiram KA at 4-Oct-12 8:55am
   
thns
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

not the nicest solution:
string test = "The Value 'sd' is not valid value";
   string[] parts = test.Split('\'');
   if (parts.Length > 2)
   {
      parts[1] = "'" + parts[1] + "'";
      MessageBox.Show("Part1: " + parts[0] + " Part2: " + parts[1] + " Part3: " + parts[2]);
   }
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid