Array as Public Property; Need to Set Value at Index
I come from C/Lua/VBA background, very new to C# or anything like it.
Using .NET 9 and Onvif.core with VScodium/Omnisharp on Windows.
Onvif.core has this class:
CapabilityCategory
is an enum:
I am trying to set the value of Category[0]
to CapabilityCategory.ALL
This:
Gives me some errors:
My normal approach of shotgunning different syntax has yielded nothing useful.
Tutorials point/W3 Schools and Microsoft documentation have also proven unhelpful.
The library documentation is non-existent, and the ONVIF Application programmer's guide is far too general in this case.
If more information is required I will be happy to provide it.
Thanks,18 Replies
You can't initialize elements in an array field like that, you'll have to assign it after creation.
I knew it would be something super simple lmao. thanks!
Actually you could also do this
(I'm dumb and this wouldn't work because you'd first have to initialize the array)
Oh I had assumed they were dynamic. Noted.
Lists are, arrays aren't
And in any case, accessing index 0 on an array or list without any elements will throw an exception.
Thinker
REPL Result: Failure
Exception: IndexOutOfRangeException
Compile: 210.594ms | Execution: 26.317ms | React with ❌ to remove this embed.
Even more so since there is no initialization of the array field. So
would throw a
NullReferenceException
.Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
I'm already compromising by being on windows and using something that isn't Neovim, but I appreciate the thought.
De-compromise by going back to Linux or Mac, and compromise by using Rider
Net zero change in compromise lol
Are you saying you’re on Windows just to learn C#?
Because you don’t need to be.
I'm on windows for other reasons, I would absolutely be doing this on Linux if I could be. I'm aware .NET 9 is cross platform.
I miss Sway every time I need to <Alt+tab> 😭
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
It's entirely personal preference, I was just stating the fact that your suggestion maligns with mine.
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View
My preferences have more to do with the two years of muscle memory and BASH experience and less to do with the politics of it lmao
Unknown User•6d ago
Message Not Public
Sign In & Join Server To View