Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Suppose I have some string like that @variable(ID), @Variable(Name)etc.

firstly I want to check if there is any @variable then I will get only ID or Name

Task 1: Check is "@variable" is available

if yes then I want take the portion which is inside in the parenthesis.

Can anyone help me to write this code ?
Posted

is the @variable word is always at the start of the string
try this

C#
var stringHolder = "@variable(ID)";
        if (stringHolder.Substring(0, "@variable".Length) == "@variable")
        {
            var getCode = stringHolder.Replace("@variable(", "").Replace(")", "");   
        }


I test my previous code,it gets error
I update my code and its work fine
 
Share this answer
 
v3
Comments
sachi Dash 20-Feb-14 3:31am    
yes, @variable word is always at the start of the string but i also need skip the parenthesis.... i need to get output id not (id). so please consider it.
The14thNoah 20-Feb-14 3:45am    
ok, .please refer to my updated 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