I have string of 9 letters.
string myString = "123987898";
I want to retrieve the first 3 letters "123" then 2 more letters "98" and then 4 more letters "7898".
Which c# string function support this functionality.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
History: The name C is derived from an earlier programming language called BCPL (Basic Combined Programming Language). BCPL had another language based on it called B: the first letter in BCPL.
You can use Substring:
myString.Substring(0,3)
myString.Substring(3,2)
myString.Substring(5,4)
It's also possible to make it more complicated than necessary by using a combination of regular expressions and LINQ:
string myString = "123987898";
Regex regex = new Regex("(.{3})(.{2})(.{4})");
string[] bits = regex
.Match(myString)
.Groups
.Cast<Group>()
.Skip(1)
.Select(match => match.Value)
.ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With