`System.String` doesn't have the `Substring` method or something is weird about this string??
i've even tried this
but here's my substring operation:
it works for some returned strings but not all????
56 Replies
There's only one string in C#
It's not rust that has 163 different types
LOL
i meant though that
some strings can be substringed but for others
it erros
errors
let me try to catch the error
since its not killing my code for some reason
i see now
C# is super strict about these things i guess
should i just make a ternary to check if it needs to be substringed?
Remember, that arrays in C# are 0-indexed
well this sort of thing works in JS and lua
i forgot these kind of languages enforce these operations
So
arr[..123]
on an array that has .Length
of length 123 won't workyea true so
i guess i should just check
if its over the length i need
im used to js handling it regardless
oh also i started using classes for web results and the standard serializer
henkey helped me =D
its not that bad
This should work
Or, yeah, a ternary
how woulx this work?
would*
Math.Min(a, b)
picks the lowest value
So if the string is 2839746 chars long, and the max is 100, it will take a substring of length 100
If the string is 2 chars long, and the max is 100, it will take a substring of length 2, so the whole string
There might be some off-by-one errors here, so you'd have to actually run this code and check loloh that makes sense
should i put 2042 if i want it to
go to the 2043rd index lol
2043rd item, that resides on the 2042nd index, yeah
0-indexed and all that
worked! tysmmm
ive never rlly used math functons that much
functions
besides rounding and randomization lol
never really needed it
could you possibly help me with one more thing?
Shoot
okay so i have a file of commands right
and groups in other files, etc. u get the point
but errors dont kill my code or throw in a fatal manner
how do i get these errors to be recognized?
so i can do debugging faster
Do you have an
async void
method somewhere, by chance?uhh
That will discard exceptions
dont think so
let me check
let me send u all of the points where the cmd method is recognized
first when initiating the command
then when checking for the command
is this because its a void?
No,
void
alone is finehm
It's specifically
async void
that causes issuesweird..
Well, it can be something else
Any
try-catch
blocks that discard the exception maybe?nope
there are none
they dont kill my program but
they do stop the code
from running at times
heres what one of the commands would look like
i dont want to try catch all of the cmds lol
Ah, wait, so this line
invokes an async method?
ya
i can't await it
apparently
its the only way i could think of to
fetch command responses
You can cast the return to a
Task<T>
elaborate
Or, well, just
Task
in this casethe return of which area
?
ohh i thought so
i didnt think of that haha
seems fine?
LGTM
lol i learned abt the null-forgiving operator
its so useful
I prefer checking for null, but you do you
how can i turn this async?
since i need to await it in every context
to get the errors
Func<ElfinClient, ElfinCommandContext, Task>
hmm
Or use a delegate type
ONE LAST QIOIUOIOIOEIOIOISOIOIOTIOIIOIOOIOIOINOIOIOQ
sorry my macro oops
so im trying to create a serializeable type for
a web response
thats n array
an*
of objects
but
Directory
and Image
come out as null
heres an example object
im not sure why it wouldnt work
im trying to do this
but all of the values are appearing as null
hmm
oh i think its the
json property name thats missingOr json serializer options
To ignore the property name case
that didnt work last time sadly
henky said it was better to specify the name
for each property
Ugh, if you want a ton of work, sure
yea ik
the configuration didnt work for me
for some reason
so i tried doing this and
now all the objects are empty.
u need
.Count
Angius#1586
REPL Result: Success
Result: SafeBooruResponse
Compile: 692.324ms | Execution: 91.639ms | React with ❌ to remove this embed.
¯\_(ツ)_/¯
idk why it doesnt work for me..
let me try hold on
Are you sure the response you get from the API is just a straight array of objects?
yes
its an array
of objects
Give me a sample URL you're getting a response from?
oh so NOW it wants to work
🙄
tysm for ur help forreal
you have gotten me thru C# so fast already
Anytime 👌
❤️