❔ I'm not sure what's wrong with my code
I don't know why Thompson still pop up only T should be. (The blue outline is what I'm trying to do)
29 Replies
@ASIAN af try with surname[0]
What does Remove do?
it removes the word in that Text
or string
String.Remove Method (System)
Returns a new string in which a specified number of characters from the current string are deleted.
Strings are immutable.
like this right?
Remove produces a new string. You aren't looking at the return value though.
You are calling Remove and throwing away the result.
so I still need to grab it?
You need to assign the result to something, yes.
mtreit#6470
REPL Result: Success
Console Output
Compile: 513.050ms | Execution: 65.887ms | React with ❌ to remove this embed.
or could I just add it to lbloutput?
like this
Yes you can do that as well.
oh
this stuff is getting hard
another question how do I remove the starting number/word?
That line of code you wrote where you are doing everything in one line: I avoid writing code like that. I think it's better to break up each task you are doing into smaller tasks and then put them all together. Then it's easier to debug and to reason about what's going on in each line of code.
Which starting number ?
if you look at the image 980529 I'm trying to remove 9
You can use
string.Substring
mtreit#6470
REPL Result: Success
Console Output
Compile: 514.484ms | Execution: 64.253ms | React with ❌ to remove this embed.
OOh
okay I did it like this
doesn't T start as 0?
like Thompson
01234567
Yes, "T" is at index 0 in the string "Thompson" if that's what you're asking.
I'm not sure I understood the question.
sorry for the bad english but yeah that's what I'm trying to sya
say
then could I do Remove(0)?
Returns a new string in which all the characters in the current instance, beginning at a specified position and continuing through the last position, have been deleted.If you read that definition, what does it mean to pass 0? In other words: "Start at position zero and delete everything from that position to the end of the string." So passing zero deletes everything. If you're not sure what a method does, you should definitely read the documentation for it:
String.Remove Method (System)
Returns a new string in which a specified number of characters from the current string are deleted.
oh okay thanks I'll read through it
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.