[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

read part of string... c#

var strName = "2013_1_Region1_101_1_Site01.png;"

Question: How can I get the value of 101 from  strName.

Always between 3rd and 4th _

Thank you.
0
Mike Eghtebas
Asked:
Mike Eghtebas
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
Shaun KlineLead Software EngineerCommented:
You can use the string.split command to split the string on the underscore and then get element 3 in the array.
0
 
käµfm³d 👽Commented:
The simplest (code-wise) solution would be to split the string on the underscore, and then examine the 4th array item.

e.g.

var split = strName.Split('_');
var _101Value = split[3];

Open in new window

0
 
käµfm³d 👽Commented:
Aw man! Beat me by 2 seconds?!?!?!

= D
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
kaufmed,

But you gave me what I could use. Respectfully, with Shuan's post, I needed to search or post yet another question to find out how split works.

Thanks to all,

Mike
0
 
AndyAinscowCommented:
Interesting EEple, but is it a pair of blue shorts with eye-holes cut in them I ask myself.  ;-)
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
It is code Ninja.
0
 
käµfm³d 👽Commented:
0
 
AndyAinscowCommented:
Aha - and on wikipedia interesting how he got his nickname (but how did that incident start?).
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now