© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
41 replies
Zenternion

InvalidCastException Specified cast is not valid.

public void DestroyCities() //102
    { //103
        foreach(GameObject go in transform) //104
        { //105
            do {
                StartCoroutine(DestroyFastly(go));
            } while(go != null);
        }
    }
public void DestroyCities() //102
    { //103
        foreach(GameObject go in transform) //104
        { //105
            do {
                StartCoroutine(DestroyFastly(go));
            } while(go != null);
        }
    }
Why is this happening
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

InvalidCastException: Unable to cast object of type
C#CC# / help
13mo ago
❔ AvaloniaUI InvalidCastException
C#CC# / help
4y ago
❔ Cast is not valid when casting interface to comcrete impl
C#CC# / help
3y ago
✅ WinForms - Parameter is not valid?
C#CC# / help
2y ago