© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
1 reply
axo

✅ ternary select between static classes

i have two static classes like this
public static class WhitePieces
{
    ...
}
public static class BlackPieces
{
    ...
}
public static class WhitePieces
{
    ...
}
public static class BlackPieces
{
    ...
}


and i'm trying to select between them like this
var pieceClass = sideAttacking == Colour.White ? WhitePieces : BlackPieces;
var pieceClass = sideAttacking == Colour.White ? WhitePieces : BlackPieces;


and i'm getting this error:
'WhitePieces' is a type, which is not valid in the given context
'WhitePieces' is a type, which is not valid in the given context


why is that?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Static vs Non-Static classes [Answered]
C#CC# / help
4y ago
Static Classes without Implementation
C#CC# / help
2y ago
data transfer between classes
C#CC# / help
4y ago
Do static classes leak memory?
C#CC# / help
3y ago