30 Replies
example i want to assign A+ to 4.0
Sounds like you want a Dictionary<string, float>, right?
what is best method to do that
yeah
how can i do that ?
Like any dictionary
Ah, beat me to it
so i don't need the second array?
because i can already assign it with this way right?
Yeah
Depends on whether you need access to an array of the potential grades outside of the dictionary lookup, but you could also get the Values of the dictionary in case you need that
Angius
REPL Result: Success
Result: float
Compile: 301.948ms | Execution: 31.578ms | React with ❌ to remove this embed.
nice
Have a look at https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.zip?view=net-8.0 maybe it is also suitable for you if you want to keep two value sources initially
Enumerable.Zip Method (System.Linq)
Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
what is wrong here?
- You're reusing the variable name "grades", that's not valid C#
- The
grades["B+"];
is a noop, you are not using it for anythingi want to display it it doesn't
I think what you want to do is, removing or renaming either the array or the dictionary, removing the grades["B+"] line, read the input and then look up the result and output it again
Ah, or that
mayybe yeah
I mean I could just drop you the code but we can also step through
Did you remove the
string[] grades
for now?
Or do you still need it for your sample?nvm
i amm so stupid xd
it worked
Nice 👍
i can remove the string array now
i don't need it
so
i want to read the grade
even if i did this
Console.ReadLine()
does not take any arguments
You want to use it to take user input
Then use that input to look up the grade
Then write that grade out
?
Not whatsoever, no
i got it
ngl
i asked chatgpt
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
i don't use it to generate code i use it to explain errors and bugs
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View