Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Using stackalloc span in if statement - C#
C
C#
•
15mo ago
•
4 replies
jborean
Using stackalloc span in if statement
Hi I
’m trying to use a span allocated on the stack of the function but it fails unless I reference the stack outside of an if statement
. An example of this compiler error can be seen at
https://sharplab.io/#v2:D4AQTAjAsAUCAMACEEB0BJA8gblrEAzMmIgMKIDesiNyRIALIgLIAUAlJdbTwEoCmAQwAmmAHYAbAJ4BlAA6CxAHgDGAC0EAnAHyJhAS00z+CzYIAuAe02kNmgM6IAvIgDa3Hp8QAFC2tQAIob8KlaasiZaFta2WgA0Hl60vub+AIIS5kGaIWERptE2dok8ALq4MEmIAiLi0vKKqna6CqnOiABEqN0dFVUltABm1kLqiKy8igDm/Ij2/FMAtvxi5oj6Yoit/vIS+uasKf5HxgVh7OwDNFSVVbQ1opKyCsrqWror5uHt267zS59yldPPpBuMAISsT7hVAAGRWUzaThcEEQADI0YhoVJXPBSs4XAByAD0hIuwJ4NzuSWx7WxqAAKpp9IsAKJiYSsAxGSJmMKxBzsPrUxAAXwptAlNBQAE4oasYQzLDIvhsphwhcDxbcaNrRUA=
Is this at all possible to achieve
?
SharpLab
C
#
/VB
/F
# compiler playground
.
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
new Span vs stackalloc
C
C# / help
2y ago
Stackalloc a span of tuples?
C
C# / help
3mo ago
✅ If statement.
C
C# / help
4y ago