C
C#7mo ago
Richards

No inbuilt functions

Hello, im a year 1 student so my knowledge is not that massive. So i have this task for university where we have to do multiple steps without using inbuilt functions except length so my question is, are there any ways to change from lowercase to uppercase without ToUpper, and how to split row1 user text in half and put row2 text in middle of row1. Thanks in advance if anyone akshully
9 Replies
Angius
Angius7mo ago
The fun thing about chars is that they're numbers under the hood
MODiX
MODiX7mo ago
Angius
REPL Result: Success
(char)('a' - 32)
(char)('a' - 32)
Result: char
A
A
Compile: 360.183ms | Execution: 24.469ms | React with ❌ to remove this embed.
Angius
Angius7mo ago
An uppercase version of a letter has an ASCII value 32 lower than the lowercase
Richards
Richards7mo ago
well we had to make user input then you type something random, and if the program sees lowercase it trasnforms that letter into uppercase, but catpat
Angius
Angius7mo ago
And this is how you can transform lowercase into uppercase without using .ToUpper() A string is just a char[] under the hood Loop over the string, uppercase each char Assemble the string back with new string(char[])
SeanJ
SeanJ7mo ago
For the second part find the middle by deviding the length by two and then do a loop of some sort to achieve what you're trying to achieve
Angius
Angius7mo ago
Yep
Richards
Richards7mo ago
Ok
Angius
Angius7mo ago
Loop over the outer string, when you hit the midpoint loop over the inner string, go back to the outer string
Want results from more Discord servers?
Add your server
More Posts