I am unaware on how to fix this conversion error
it's saying i can't convert from string to int, though I am unsure why when i used the string.format method to represent my int variable ID as a string and display it in my output file. I have three separte files for a regular user logging in, an administrator, and thena file to put the whole program together.
here is admin and the full program since that is where the issue lies
39 Replies
now part of the file to put it all together
i get the error where it says "admin = new(nextItem[2]);"
Because... it's a string
nextItem
is an array of strings
string[]
, it says so right there
So, every element of that array will be a string
If you want to parse a string to an int, use int.TryParse()
Also, why not just use Json instead of fiddling around with stringifying the data manually?bc that’s the way my prof wants it done
we are learning overriding
and i want it to stay a string that’s why i was confused
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Or better yet, use string interpolation instead
this is the way my prof is teaching it and the way he expects us to do it as well
he hasn’t taught us that yet so idk what that is
he requires doc strings and said we will use a large chunk of points if we don’t use them too
i get this seems impractical but i just think my profs teaching style is outdated
that's interpolation
would we be able to work around that ?
alright thank u
And yes, it does seem like yout teacher is another one of the fossils that stopped developing their skills in 1999
HAHAHAHAHAHAHAHAA
i’ve gotten help before here and ppl were so confused why i did code the way i did. i must always explain my prof’s teaching style
Aside from that tho, my goal is to turn the ID number into a strong but it keeps trying to turn it into an int but idk how to make that go away
Administrator ctor takes an int
You must give it an int
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
i did give an int, but at the end, i wanted to display it all as a string like my prof did
lemme show u what he did
plz hold
here's his entire code for the first part
of his example code
Jesus
yeah i was NOT joking lmao
Well
If you have something that inherits from
GenericItem
, and the point is to learn about overrides, you can override the Stringify()
methodI DID
idk y that caps
sorry
i did
one momebt
So... what's the problem?
whenever i try calling it
The format expects one parameter
With a wrong ID to boot
oops hang on i did it wong
But you pass it two parameters
how if i am just referencing to the original stringify()
it should have everything in the base including what i am adding
like what he did
If you override a method, you provide a whole entire new implementation of it
his override
Yeah
Two params in the format string
which is pretty much what i did
Two params given
Works
Your example has one param in the format string
With ID
1
instead of 0
And you give it two values
Does not computedude u wanna know what's crazy
i had something completely different there before that required a {0} and a {1} and deleted the wrong one
im gonna throw up
no way it was that simple of an error
ugh
plz hold
Angius
REPL Result: Success
Result: string
Compile: 464.220ms | Execution: 29.099ms | React with ❌ to remove this embed.
no i get how that works ijust, accidentally put the wrong number and didn't realize
ugh
thank u so much im glad that part is fixed but
the error is still showing in the main program
"cannot convert string to int"
Probably the same line as at the beginning
Your constructor takes an
int
You're giving it a string
Square peg does not fit round hole
how would i work around it like he did ? cause he nearly did the same thing
You... wouldn't?
You'd convert that string to an integer
That's that
okay plz hold
ok i have no mor eof those errors per say but now it's saying i have no static main method whent= i do
i have this
Main
C# is case-sensitive
im still thinking in terms of c++ ughhhhh
thank you
it's always the tiniest things