Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string x = "O rato roeu a rolha...";
- string y = "...da garrafa do rei da Rússia";
- Console.WriteLine("A string x tem {0} carateres", x.Length);
- if (x.Contains("rolha")) {
- Console.WriteLine("A string x contém a palavra \"rolha\"");
- }
- Console.WriteLine("A palavra roeu começa no índice {0}", x.IndexOf("roeu"));
- Console.WriteLine("Indice da última ocorrência do carater 'i': {0}", y.LastIndexOf('i'));
- string x2 = "Análise da frase: \"\"";
- x2 = x2.Insert(19, x);
- Console.WriteLine("String x2: {0}", x2);
- string z = "O rato roeu a rolha...";
- z = z.Replace(' ', '_');
- Console.WriteLine("String z: {0}", z);
- Console.WriteLine("String y em maiúsculas: {0}", y.ToUpper());
- x = x.ToUpper();
- Console.WriteLine("String x em maiúsculas: {0}", x);
- Console.WriteLine("Primeiro carater da string x: {0}", x.Substring(0, 1));
- Console.WriteLine("Ultimo carater da string x: {0}", x.Substring(x.Length - 1));
- Console.WriteLine("Todos os carateres da string y exceto o primeiro: {0}", y.Substring(1));
- Console.WriteLine("4º carater da string y: {0}", y.Substring(3, 1));
- Console.WriteLine("3 primeiros carateres da string x: {0}", x.Substring(0, 3));
- Console.WriteLine("3 últimos carateres da string x: {0}", x.Substring(x.Lenght - 3));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement