Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Unity 3D Cannot Cannot implicitly convert type `void' to `Arrays.Sonic'


  • Please log in to reply
4 replies to this topic

#1 sonic_944

sonic_944

  • Members
  • 117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:25 PM

Posted 01 July 2014 - 03:19 PM

    public class Sonic {
        
    string sonic;
    string tails;
    string big;
    string chao;
        
    public void Chaos () {
    
    print("Sonic" + sonic);
    print("Tails" + tails);
    print("Chao" + chao);
    print ("Big" + big);
            
    }        
    
    // Use this for initialization
    void Start () {
    
    Sonic[] milesTails = new Sonic[4];
    milesTails[0] = new Sonic();
    milesTails[1] = new Sonic();
    milesTails[2] = new Sonic();
    milesTails[3] = new Sonic();
            
    milesTails[0].sonic = "Sonic";         
    milesTails[1].tails    = "Tails";
    milesTails[2].big = "Big";
    milesTails[3].chao = "Chao";
    
    milesTails[0] = Chaos();
    milesTails[1] = Chaos();
    milesTails[2] = Chaos();
    milesTails[3] = Chaos ();         
            
                
    }
    

    }        
        
}

 

EDIT: If there's any other errors please let me know. I am new to programming.

 

EDIT 2: THe Error is on line 32.


Edited by sonic_944, 01 July 2014 - 03:47 PM.


BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:03:25 PM

Posted 01 July 2014 - 03:30 PM

Cannot implicitly convert "blob of code" into question. What's your question?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 sonic_944

sonic_944
  • Topic Starter

  • Members
  • 117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:25 PM

Posted 01 July 2014 - 03:32 PM

Well Unity said that Assets/Arrays.cs(41,9): error CS0029: Cannot implicitly convert type `void' to `Arrays.Sonic' and I want to know why. This is for making arrays.



#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:03:25 PM

Posted 01 July 2014 - 03:45 PM

We don't know which line that is. We don't know what you've tried. The error message quite succinctly explains why that is -- you tried to put something in a variable of one type into a variable of another type, which is not allowed.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#5 sonic_944

sonic_944
  • Topic Starter

  • Members
  • 117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:25 PM

Posted 01 July 2014 - 03:50 PM

I deleted the bottom four

  
    milesTails[0] = Chaos();
    milesTails[1] = Chaos();
    milesTails[2] = Chaos();
    milesTails[3] = Chaos ();  

 

so it's that.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users