Skip to main content

All Questions

-3 votes
2 answers
67 views

How can I use a modified String in a C# switch → case statement?

I have a string I need to use, a variant of, in many places throughout my application. For example: String myString = "The Quick Brown Fox"; string someLowerCaseString = myString.ToLower(); ...
Brian's user avatar
  • 1,909
0 votes
0 answers
95 views

Using String values in switch and StringLists in case

I have two different String lists: firstList [a, b, c] and secondList [d, e, f]. Is there a way I can use a list in a case statement? To be clear, the intended behavior is something like this: switch(&...
lodarius's user avatar
0 votes
2 answers
99 views

How to convert a string that currently has a switch parameter into a function in powershell

I have a string like this: "CleanUp -All" How do you convert it into a callable function in PowerShell including the switch? I tried calling "&" in front of the entire string. ...
davidprogrammercdn's user avatar
-5 votes
2 answers
78 views

Strings || Case Sensitive

Need to make a password program, where the user sets a password at the beginning and the password can be entered 3 times before the program is stopped. The program can not be case sensitive. ...
Ehxo's user avatar
  • 11
0 votes
1 answer
431 views

C++ Switch statement using strings

I am fully aware that switch must be used with int, but my assignment is requiring me to use switch in regards to user input which will be strings. I've looked and I've seen some mentioning stoi, but ...
raelyn's user avatar
  • 17
0 votes
1 answer
2k views

Using a string with switch/case [duplicate]

Right now, I have the following switch-case, built using an enum representing some text. String inputMessage = Serial.readString(); //Input is either TEXT_1 or TEXT_2. enum Messages { ...
HFOrangefish's user avatar
0 votes
3 answers
436 views

How to replace 1 string with 2 strings in an array?

Here's an example: I have this array: const chars = [ "ä", "t", "i" ] and I'd like to achieve this outcome: const chars = ["a", "e", "t", &...
Ives E.'s user avatar
  • 93
0 votes
0 answers
40 views

Are Strings Interned When Used As Return Values in Switch Statements?

Say I write a switch statement where the return value is a string. Are the strings that this switch statements return interned (since they may be referenced many times)? Say we have an enumeration ...
Tea's user avatar
  • 170
1 vote
5 answers
1k views

Is it possible to use Integers and Strings as cases in a switch case?

I've done some looking around and haven't really found much direct info on this so I'd like to just ask it directly. Is it possible to use integers and strings in a switch case? I know the switch is ...
NobleRuckus's user avatar
-1 votes
1 answer
113 views

The code works in some cases but gives different outputs based on the sequence of the input

Expected Output should be as such: Download String: Welcome to HackerRank's Java tutorials! Double: 3.1415 Int: 42 My code gives different outputs based on what input I put in at first. If possible ...
vlad19's user avatar
  • 1
1 vote
1 answer
684 views

Incompatible operand types Scanner and String?

I keep getting the following errors: Incompatible operand types Scanner and String Incompatible operand types int and String before I added the int op = Integer.valueOf(operator) line it kept giving ...
Jeseca Z's user avatar
-1 votes
2 answers
912 views

How to return arrays in switch-case statement in Java? [duplicate]

The essence of the problem: you need to implement a public static method that returns an array of two elements - the names of the days off in English. The method accepts a parameter as input - the ...
Pete Alexandrovich's user avatar
0 votes
1 answer
57 views

how to find if a string includes something in a switch() javascript

i would like to find out if a string contains a certain word using a switch() statement here is an example of what i want to use that for: let text = "among" switch(text.toLowerCase()....
NRD moment's user avatar
-1 votes
2 answers
81 views

How to display different texts in a set of Enums when a condition is true or false

In order to validate rules to answers from users to questions, consider the following set of Enums in a Java Spring Boot application; the validation is fired whenever a user answers a question in the ...
DWA's user avatar
  • 530
3 votes
2 answers
9k views

strings.Contains in switch-case GoLang [closed]

Is it possible to use strings.Contains in switch case? something like: func function(str string){ switch str { case "str1": ... case strings.Contains("test"): ...
S_Nissan's user avatar

15 30 50 per page
1
2 3 4 5
20