Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

using System;

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;

string str3 = new string('z', 4);


string str4 = new string(new char[] { 'C', 's', 'h' });

string str6 = str1.Trim();

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[] values = new string[] { str1, str2, str3 };


string str4 = String.Join(" ", values);
Console.WriteLine(str4);

foreach (var item in values)


{
Console.WriteLine(item);
}

{
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 subString = "HEdLL";


int indexOfSubstring = str1.IndexOf(subString);
Console.WriteLine(indexOfSubstring);
}

// Не шалите с этим...
//{
// 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[] { ' ' });

foreach (var item in words)


{
Console.WriteLine(item);
}
}Console.ReadKey();
{
string text = "Жизнь похожа на чашку чая...";
string[] words = text.Split(new char[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);

foreach (var item in words)


{
Console.WriteLine(item);
}
}

string str1 = "HELLO WORLD";


Console.WriteLine(str1);
str1 = str1.Trim(new char[] { 'H', 'L', 'D', 'E' });
Console.WriteLine(str1);
}

{
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);

text = text.Remove(0, 2);


Console.WriteLine(text);
}

{
string str1 = "Good day";
str1 = str1.Replace("Good", "Bad");
Console.WriteLine(str1);

str1 = str1.Replace("a", "");


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);
}

}
}
}

You might also like