String.equalsIgnoreCase()

Descrição

Verifica se duas strings são iguais. A comparação, nesse caso, não é case-sensitive, o que significa que a String "hello" é dada como igual a the String "HELLO".

Sintaxe

minhaString.equalsIgnoreCase(minhaString2)

Parâmetros

  • minhaString, minhaString2: vvariáveis do tipo String

Retorna

  • true: se minhaString é igual a minhaString2 (sem diferenciar maiúsculas e minúsculas)
  • false: otherwise

Código de Exemplo

void setup() { Serial.begin(9600); String myString = "Arduino"; if (myString.equalsIgnoreCase("ARDUINO")) Serial.println("Two strings is equal to each other"); else Serial.println("Two strings is NOT equal to each other"); } void loop() { }

The result on Serial Monitor:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Two strings is equal to each other
Ln 11, Col 1
Arduino Uno on COM15
2

※ Notas e Advertências:

If the string is modified, it is highly recommended using String.reserve() to prevent the memory fragmentation issue

Ver Também

Exemplo : Tutoriais String (Em Inglês)

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES