witam
Chciałem się was zapytać czemu w indekserze w secie dokładnie
if (tabslow[n].Contains(" "))
nie zwraca błędu, gdy przypisane są wyrazy oddzielone spacją ?
namespace ConsoleApplication16
{
class Program
{
static void Main(string[] args)
{
Zdanie s = new Zdanie("asdf sdfasdf asdfasdf");
s[1] = "sdfm sdfs";
Console.WriteLine(s[1]);
Console.ReadLine();
}
}
}
class Zdanie
{
string[] tabslow;
public Zdanie(string zdanie)
{
this.tabslow = zdanie.Split();
}
public string this[int n]
{
get
{
if (n > tabslow.Length - 1 || n < 0)
return "Przekroczono limit elementow tablicy ";
return tabslow[n];
}
set
{
if (tabslow[n].Contains(" ")) // Czemu nie wyskakuje błąd jeśli wprowadzony string zawiera spację?
{
Console.WriteLine("Nie moze zawierac spacji");
}
else
tabslow[n] = value;
}
}
}