Professional Documents
Culture Documents
String
String
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
{
string str1 = " Te xt ";
string str2 = null;
str1 = str1.Trim();
Console.WriteLine(str1);
{
string str1 = "HELLO";
string str2 = "WORLD";
string str3 = str1 + " " + str2;
string str4 = String.Concat(str3, " ", "!!!!");
int a = 2;
int b = 5;
Console.WriteLine("34" + 5);
{
string str1 = "string 1";
string str2 = "string 2";
string str3 = "string 3";
{
string str1 = "HELLO";
string str2 = "WORLD";
int result = String.Compare(str1, str2);
if (result < 0)
{
Console.WriteLine(str1 + " > " + str2);
}
else if (result > 0)
{
Console.WriteLine(str1 + " < " + str2);
}
else
{
Console.WriteLine(str1 + " == " + str2);
}
}
{
string str1 = "HELLO WORLD";
char ch = 'O';
int indexOfChar = str1.IndexOf(ch);
Console.WriteLine(str1);
Console.WriteLine(indexOfChar);
// Не шалите с этим...
//{
// string path = @"C:\folderTemp";
// string[] files = Directory.GetFiles(path);
// for (int i = 0; i < files.Length; i++)
// {
// if (files[i].EndsWith(".*"))
// File.Delete(files[i]);
// }
//}
{
string text = "Жизнь похожа на чашку чая...";
string[] words = text.Split(new char[] { ' ' });
{
string text = "Hello world";
string subString = "all ";
text = text.Insert(6, subString);
Console.WriteLine(text);
{
string text = "Good day";
int ind = text.Length - 1;
text = text.Remove(ind);
Console.WriteLine(text);
{
string str1 = "Good day";
str1 = str1.Replace("Good", "Bad");
Console.WriteLine(str1);
{
string str1 = "Hello Eldar**";
Console.WriteLine(str1.ToLower());
Console.WriteLine(str1.ToUpper());
{
string name = "John";
int age = 23;
Console.WriteLine("Имя: {0}, Возраст {1}", name, age);
Console.WriteLine($"Имя: {name}, Возраст {age}");
}
{
string name = "John";
int age = 23;
string str = String.Format("Имя: {0}, Возраст {1}", name, age);
Console.WriteLine(str);
}
{
int a = 12;
int b = 17;
string str = $"{a} + {b} = {a + b}";
Console.WriteLine(str);
Console.WriteLine((char)a);
}
}
}
}