Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Benjamen · Jun 19, 2011 at 08:29 AM · c#syntax-error

error CS1520: Class, struct, or interface method must have a return type

Error:

 Assets/Scripts/Character Classes/ModifiedStat.cs(7,16): error CS1520: Class, struct, or interface method must have a return type

Script:

 using System.Collections.Generic;
 
 public class ModifiedStabt : BaseStat {
     private List<ModifyingAttribute> _mods;
     private int _modValue;
     
     public ModifiedStat() {
         _mods = new List<ModifyingAttribute>();
         _modValue = 0;
     }
     
     public void AddModifier( ModifyingAttribute mod) {
         _mods.Add(mod);
     }
     
     private void CalculateModValue() {
         _modValue = 0;
         
         if(_mods.Count > 0)
             foreach(ModifyingAttribute att in _mods)
                 _modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
     }
     
     public new int AdjustBaseValue {
         get{ return BaseValue + BuffValue + _modValue; }
     }
     
     public void Update() {
         CalculateModValue();
     }
 }
     
 public struct ModifyingAttribute {
     public Attribute attribute;
     public float ratio;
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Skjalg · Jun 19, 2011 at 09:33 AM

You class name is called ModifiedSta*b*t (with a b before the last t), while your constructor is called ModifiedStat (without the b).

Use an editor with error highlighting like Visual Studio, and you'll see these errors easier.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
-1

Answer by Angel1024 · Oct 16, 2013 at 03:42 PM

Error CS1520: Class, struct, or interface method must have a return type (CS1520) using System; using gtk; using Pango; using System.Threading; using System.IO.Ports;

public partial class MainWindow: gtk.Window {
int minutos, segundos, bandera = 0; Thread reloj; SerialPort serial;

 public MainV ():base (Gtk.WindowType.Toplevel)
 {
     Build ();
     cajatextoA.ModifyFont(FontDescription.FromString("Arial 25"));
     cajatextoB.ModifyFont(FontDescription.FromString("Arial 25"));
     serial = new SerialPort();//Instanciamiento del puerto serial
     serial.PortName = "/dev/ttyACM0";//Se indica cual puerto será utilizado
     serial.BaudRate = 9600;//La velocidad del puerto
     serial.Open();
 }

 protected void OnDeleteEvent (object sender, DeleteEventArgs a)
 {
     Application.Quit ();
     a.RetVal = true;
     if(serial.IsOpen)//Si el puerto aun esta abierto...
         serial.Close();
 }
 protected void OnButton1Clicked (object sender, EventArgs e)
 {
     minutos = Convert.ToInt32(cajatextoA.Text)+10;
     cajatextoA.Text = ""+minutos;
     serial.Write("0");
 }    

 protected void OnButton2Clicked (object sender, EventArgs e)
 {
     minutos = Convert.ToInt32(cajatextoA.Text)+1;
     cajatextoA.Text = ""+minutos;
     serial.Write("0");
 }    

 protected void OnButton3Clicked (object sender, EventArgs e)
 {
     segundos = Convert.ToInt32(cajatextoB.Text)+10;
     if(segundos>59){
         segundos = segundos - 60;
         minutos = Convert.ToInt32(cajatextoA.Text)+1;
         cajatextoA.Text = ""+minutos;
         segundos = 0;
         cajatextoB.Text = ""+segundos;
     }else
         cajatextoB.Text = ""+segundos;
     serial.Write("0");
 }    

 protected void OnButton4Clicked (object sender, EventArgs e)
 {
     segundos = Convert.ToInt32(cajatextoB.Text)+1;
     if(segundos>59){
         segundos = segundos - 60;
         minutos = Convert.ToInt32(cajatexto.Text)+1;
         cajatextoA.Text = ""+minutos;
         segundos = 0;
         cajatextoB.Text = ""+segundos;
     }else
         cajatextoB.Text = ""+segundos;
     serial.Write("0");
 }    

 protected void OnButton5Clicked (object sender, EventArgs e)
 {
     serial.Write("2");
     if(bandera == 1){
         reloj.Resume();
         bandera = 0;
     }else{
         segundos = Convert.ToInt32 (cajatextoB.Text);
         minutos = Convert.ToInt32 (cajatextoA.Text);
         reloj = new Thread(cuentaAtras);
         reloj.Name = "Cuenta hacia atras";
         reloj.Start();
         reloj.Priority = ThreadPriority.Highest;
     }
     serial.Write("0");
 }

 protected void OnButton6Clicked (object sender, EventArgs e)
 {
     serial.Write("3");
     if(bandera == 0){    
         reloj.Suspend();
         bandera++;
     }else{
         reloj.Abort();
         cajatextoA.Text = "0";
         cajatextoB.Text = "0";
         bandera = 0;
     }
     serial.Write("0");
 }

 public void cuentaAtras ()
 {
     while (segundos != 0 || minutos != 0) {
         if (segundos > 0) {
             segundos--;
             cajatextoB.Text = Convert.ToString(segundos);
         } else if (minutos > 0) {
             minutos--;
             segundos = 59;
             cajatextoA.Text = Convert.ToString(minutos);
             cajatextoB.Text = Convert.ToString(segundos);
         }else{
             ;
         }
         Thread.Sleep (TimeSpan.FromSeconds (1));
     }
     serial.Write("1");
     reloj.Abort ();
 }

}

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Angel1024 · Oct 16, 2013 at 03:41 PM 0
Share

HELP $$anonymous$$EEEEEEEEEEEEEEEEEEEEEE

avatar image Graham-Dunnett ♦♦ · Oct 16, 2013 at 03:45 PM 0
Share

What you've posted is not an answer, and neither is it formatted correctly.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Error CS1519! Base Character script error from BurgZerg Arcade 2 Answers

Class, struct, or interface method must have a return type 2 Answers

help script error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges