51 Replies
This is the code. Im trying to return (centerX, centerY) and "No match found"
this doesn't even compile
start from the top of your program, find the first error, figure out how to fix it, repeat until there are no more errors
hint: this isn't python, everything needs to define a specific type
Maybe compiles if the Designer file defines a savedImage member for some reason
it 100% doesn't
FindMatchingImage()
has no return type, and if it did the 2 different paths try to return different types^ The current syntax is like a constructor for a non-existent class rather than a method
Methods - C# Programming Guide - C#
A method in C# is a code block that contains a series of statements. A program runs the statements by calling the method and specifying arguments.
From what I can see...
1.
FindMatchingImage
has no return type
2. You're trying to return a (int, int)
tuple out of it at one point
3. And a string
at one pointHmm, I think I fixed it
thanks
Please tell me the solution wasn't something like giving the method a return type of
object
that's... a solution
works
At least use a named tuple lmao
what is a named tuple?
"works" and "good" are not the same, if all you want is what works then sure
(int X, int Y, string message, bool success)
based on your code it looks like you want a result type, try pattern, or maybe even just throw an exception
wuduhhell omagad
what difference does it do?
it names your tuple members
it tells only a variable can be a string?
so you have
X
instead of Item1
for exampleoh
You can use
theTuple.message
instead of having to remember that the message is item 3 and using theTuple.Item3
still really not the right solution imo
if it was me i'd probably use the try pattern and leave the error message generation to code outside the method
Something is strange
why it doesnt type to locals?
?
what is "type to locals"
centerX and centerY are locals, according to lua
this isn't lua
so what does that mean in the context of C#
true but still I dont know any other name for them
if i don't know what "type to locals" means i can't tell you why it's doing whatever that is
a variable
not helping
Int
i see nothing wrong here, why are you confused?
besides what i'm assuming is a NRT warning
Should have typed
so you want to see the inline hints?
A warning that is telling it may not exist
that's an IDE feature, it's not part of your code and means nothing
it's just to help you remember what the parameter name is
ok then
if you want to see it all the time you'll have to configure that in your editor
nah, its ok
but i will reiterate, this is a hacky solution and i don't recommend keeping it like this
unless all you want is something that "works"
hacky means what?
it means like, if I make a server with that code, my server can get hacked?
no, like it's not a very elegant solution
like i said, "code that works" and "code that is good" are different categories
trust me, i inherited a ton of projects where they only cared about writing code that works and it's very difficult to work on
Its more like about making other people to be able to read the code tho
but yeah, I get it
"other people" includes you in a few weeks when you look at this code again 😛
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.