Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
CSS
i want to find the DatasetID from the string str.
string str={ DatasetID = 13, DatasetName = Assigned Form Submission };

please help me.
Posted
Comments
BillWoodruff 24-Sep-13 5:59am    
Is there a reason you did not put the string in quotes ?

Locate DatabaseId in the string. From that locaton take a substring till the ',' character.
That should give you the id.
 
Share this answer
 
You can write different methods to find the Dataset ID. This might be very useful to get the ID.

C#
private void FindMethod()
{
   string str="{ DatasetID = 13, DatasetName = Assigned Form Submission }";
   int first = str.IndexOf("=") + "=".Length;
   int last = str.LastIndexOf(",");
   string str2 = str.Substring(first, last - first).Trim();
   System.Console.WriteLine("DataSet ID: '{0}'", str2);
}
 
Share this answer
 
Rapid solution :

C#
string str="{ DatasetID = 13, DatasetName = Assigned Form Submission }";
            string DatasetId = str.Substring(str.IndexOf('=')+1,str.IndexOf(',')-str.IndexOf('=')-1).Trim();


But you should parse all and create an object from it
 
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