Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sir,
i have one string variable like below

string ts="2.00:00:00";
i want to cut this string and store only "2" into another string variable.
i want to do string cut="2"


plz help...
Posted
Updated 14-Apr-14 18:45pm
v3

VB
string s = "2.00:00:00";
    //
    // Split string on spaces.
    // ... This will separate all the words.
    //
    string[] words = s.Split('.');

words[0] get the result : 2
 
Share this answer
 
Comments
Rahul VB 14-Apr-14 8:54am    
perfect
C#
string ts = "2.00:00:00";

string[] split = ts.(new Char [] {'.'});

if(split.length > 0)
{
    Console.Write(split[0]);
}
 
Share this answer
 
Comments
Rahul VB 14-Apr-14 8:55am    
even better +5
Manas Bhardwaj 14-Apr-14 10:07am    
thx!
Another option is SUBSTRING

Eg:
C#
string newword = "2.00:00:00";
string cut= newword.Substring(0, 1);
 
Share this answer
 

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