Тема: Чому не виводиться деструктор
using System;
using System.Linq;
namespace Lab_2
{
public class Word
{
private string name;
public Word()
{
name = "something";
}
public void SearchNumbersCount(string word) => Console.WriteLine($"Digits count in word is {word.Where(c => char.IsDigit(c)).Count()}");
~Word()
{
Console.WriteLine("destructor");
}
}
class Program
{
static void Main()
{
Word word = new Word();
string[] strArray = new string[0];
string @string = "";
while (@string != "stop")
{
Console.Write($"Enter word: ");
@string = Console.ReadLine();
word.SearchNumbersCount(@string);
Array.Resize(ref strArray, strArray.Length + 1);
strArray[strArray.Length - 1] = @string;
}
int CompareStrings(string str1, string str2)
{
int number1 = (from n in str1 where char.IsDigit(n) select n).Count();
int number2 = (from n in str2 where char.IsDigit(n) select n).Count();
if (number1 > number2)
{
return 1;
}
else
return -1;
}
string s = string.Empty;
for (int i = 0; i < strArray.Length - 1; i++)
{
for (int j = i; j >= 0; j--)
{
if (CompareStrings(strArray[j], strArray[j + 1]) < 0)
{
s = strArray[j];
strArray[j] = strArray[j + 1];
strArray[j + 1] = s;
}
}
}
for (int i = 0; i < strArray.Length; i++) Console.WriteLine(strArray[i]);
Console.ReadLine();
}
}
}