Halloween Special 2026! Get Up to 25% OFF Practice Questions! Limited Time - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Blockchain CBDE Exam - Topic 5 Question 118 Discussion

Posted by Rosita on Oct 27, 2025 at 03:23 AM

To compare a String in Solidity you use:

Suggested Answer: C

Get Premium CBDE Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
27 comments · newest first
DE
Denny 8 months ago
I disagree, A should work in some cases too!
EM
Emogene 8 months ago
Wait, you can't compare strings directly? That's surprising!
DA
Dana 8 months ago
D is actually a common workaround, but not always reliable.
AS
Ashanti 9 months ago
I thought you could just use A? Seems easier.
JU
Julianna 9 months ago
C is the way to go, hashing is the best method!
SH
Shonda 9 months ago
Hashing strings? What is this, the 1980s? Real developers use the Force to compare strings.
RA
Rasheeda 9 months ago
B) sounds like it might work, but I've never heard of that "str_compare" function. Hashing is the way to go.
ME
Melinda 9 months ago
D) is interesting, but it's not the best solution. Hashing the strings is more reliable.
DA
Daniel 9 months ago
A) is just plain wrong. You can't compare strings like that in Solidity.
TH
Thea 10 months ago
C) is the correct answer. Comparing strings directly in Solidity is not possible, so hashing them and comparing the hashes is the way to go.
CE
Ceola 10 months ago
I thought we could compare strings directly with ==, but now I'm questioning if that's only for bytes.
HE
Herminia 10 months ago
I feel like I saw a practice question that mentioned hashing strings, which makes me lean towards C as well.
MI
Miss 10 months ago
C makes sense. Hashing avoids issues with string encoding.
MA
Mable 10 months ago
I prefer D. Converting to bytes32 seems straightforward.
DA
Daniel 10 months ago
I think it's C. Hashing is the way to go.
SA
Sanjuana 11 months ago
A is wrong, right? Direct comparison doesn't work.
VI
Viva 11 months ago
I remember something about using bytes32 for comparison, so could it be D? But I'm not entirely sure.
ER
Erick 11 months ago
I think you can't directly compare strings in Solidity, so maybe it's C? That sounds familiar.
LA
Laticia 12 months ago
I'm a bit confused on this one. I know there are some tricks to comparing strings in Solidity, but I can't recall the exact method. I'll have to review my notes before answering this.
LA
Lavera 12 months ago
Ah, I remember learning about this. I believe the correct answer is D - you can convert the strings to bytes32 and then compare them that way. Seems like a straightforward solution.
BE
Ben 12 months ago
Hmm, I'm not sure about this one. I know you can't directly compare strings, but I'm not confident which method is the best way to do it. I'll have to think this through carefully.
KI
Kina 1 year ago
I think the answer is C. Comparing strings directly can be tricky in Solidity, so hashing them and comparing the hashes is a good approach.
FR
Francisca 7 months ago
↳ replying to Kina
Definitely C, better for security and accuracy.
DA
Davida 7 months ago
↳ replying to Kina
I like option C as well, avoids pitfalls.
RO
Ronald 7 months ago
↳ replying to Kina
Direct comparison can lead to issues, hashing is the way!
JA
Jaime 7 months ago
↳ replying to Kina
I agree, hashing is safer for string comparison.
VI
Viola 11 months ago
↳ replying to Kina
C makes the most sense to me too.
0/2000 characters

Save Cancel