0

String to bool? How?

Hello! How can i fix my CS0019 { /Playground/file0.cs(13,21): error CS0019: Operator '||' cannot be applied to operands of type 'bool' and 'string' ./Playground/file0.cs(21,21): error CS0019: Operator '||' cannot be applied to operands of type 'bool' and 'string' ./Playground/file0.cs(29,21): error CS0019: Operator '||' cannot be applied to operands of type 'bool' and 'string' } in this programm? using System; namespace SoloLearn { class Program { static void Settings(string a, string b, string c) { bool symbols; bool topletter; bool letter; { if (a == "Y" || "y" || "Yes" || "yes") { symbols = true; } else { symbols = false; } if (b == "Y" || "y" || "Yes" || "yes") { letter = true; } else { letter = false; } if (c == "Y" || "y" || "Yes" || "yes") { topletter = true; } else { topletter = false; } } } static void Main(string[] args) { string a, b, c; Console.WriteLine("Please wright length of your pASSword:"); string lengthstring = Console.ReadLine(); int length = Int32.Parse(lengthstring); Console.WriteLine("Do you need symbols?"); a = Console.ReadLine(); Console.WriteLine("Do you need Letters?"); b = Console.ReadLine(); Console.WriteLine("Do you need TOP Letters?"); c = Console.ReadLine(); Settings(a, b, c); } } }

20th Jan 2020, 11:14 AM
Ilya Amiranidze
Ilya Amiranidze - avatar
1 Réponse
+ 3
a=="y"||a=="Y"||a=="yes"||a=="Yes"
20th Jan 2020, 11:17 AM
Igor Kostrikin
Igor Kostrikin - avatar