Last active
March 23, 2021 11:41
-
-
Save luisdeol/f0fc29cae9de8f08a5db5013d7d795ab to your computer and use it in GitHub Desktop.
Artigo Manipulando Strings com C# - Buscas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ManipulandoStrings | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
const string frase = "LuisDev é um blog do Luis Felipe"; | |
var luisIndexOf = frase.IndexOf("Luis"); | |
var blogIndexOf = frase.IndexOf("blog"); | |
var luisLastIndexOf = frase.LastIndexOf("Luis"); | |
var luisStartsWith = frase.StartsWith("Luis"); | |
var luisContains = frase.Contains("Luis"); | |
var blogSubstring = frase.Substring(blogIndexOf, 4); | |
Console.WriteLine($"Índice de primeira ocorrência de Luis: {luisIndexOf}"); | |
Console.WriteLine($"Índice de primeira ocorrência de blog: {blogIndexOf}"); | |
Console.WriteLine($"Índice de última ocorrência de Luis: {luisLastIndexOf}"); | |
Console.WriteLine($"String começa com Luis: {luisStartsWith}"); | |
Console.WriteLine($"String contém Luis: {luisContains}"); | |
Console.WriteLine($"Substring de blog: {blogSubstring}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment