using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace P12_string
{
class Program
{
static void Main(string[] args)
{
string s = "ana are mere";
Console.WriteLine(s.IndexOf('r'));//cauta caracter
Console.WriteLine(s.IndexOf("mere"));//cauta sir
Console.WriteLine(s.IndexOf('r', 3, 3));//cauta caracter de la pozizia 3, pe 3 caractere
s=s.Insert(8, "multe ");//inserez sir la pozitia
Console.WriteLine(s);
s = s.Remove(13);//sterge tot de la poz 13 pana la final
Console.WriteLine(s);
s = s.Remove(5,3);//sterge 3 caractere de la poz 5
Console.WriteLine(s);
s = s.Replace('a', '*');//inlocuiesc a cu *
Console.WriteLine(s);
s = "ana are mere";
s = s.Substring(4);// ia sirul incepand cu poz 4
Console.WriteLine(s);
s = s.Substring(2, 3);//ia primele 3 caractere de la poz 2
Console.WriteLine(s);
s = "ana are mere";
s = s.ToUpper();//transforma literele mici in mari
Console.WriteLine(s);
s = s.ToLower();//transforma literele mari in mici
Console.WriteLine(s);
s = " " + s + " ";
Console.WriteLine(s);
s = s.Trim();//elimina spatiile de la inceput si sfarsit
Console.WriteLine(s);
Console.ReadKey();
}
}
}
|