Neo
Neo

Reputation: 16239

Need to use substring function for all cases?

My customer number is CUS/ABC/15

for this i have used substring like

string newNo = "CUSTNO"+custobj.CustomerNumber.Substring(custobj.CustomerNumber.LastIndexOf("/") + 1, 2);

output CUSTNO15

But I want to use substring as default method. for example

if my customer number is CUST/AB/62

now to take out 62 i need to modify substring as below

CUSTNO"+custobj.CustomerNumber.Substring(custobj.CustomerNumber.LastIndexOf("/"));

How can I make it default irrespective of customer number ?

Upvotes: 0

Views: 52

Answers (1)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73492

You can use Split method.

var num = text.Split('/')[2];

If you're asking for something else please provide more info

Upvotes: 1

Related Questions