Skip to content

Repository ini berisi tentang studi kasus mencari kata dan kalimat di dalam tanda kurung dengan bahasa pemrograman C#

Notifications You must be signed in to change notification settings

rhmau1/looking-for-words-in-parentheses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

looking-for-words-in-parentheses

We will learn about how to get words or character inside of parentheses in C#
IndexOf() gives you the first position of a character or string inside of another string.
IndexOf() returns -1 if it can't find a match.
Substring() returns just the specified portion of a string, using a starting position and optional length.


Example:

string message = "Find what is (inside the parentheses)";

int openingPosition = message.IndexOf('(');
int closingPosition = message.IndexOf(')');

openingPosition += 1;

int length = closingPosition - openingPosition;
Console.WriteLine(message.Substring(openingPosition, length));

That code will return output like this: inside the parentheses


We can use the IndexOfAny() method to find the first location of any of the string from selected array.
And we can also use LastIndexOf() to find the final location of a string within another string.
Source: https://learn.microsoft.com/id-id/training/modules/csharp-modify-content/2-exercise-indexof-substring

About

Repository ini berisi tentang studi kasus mencari kata dan kalimat di dalam tanda kurung dengan bahasa pemrograman C#

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages