- Home /
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;
}
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.
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 ();
}
}
What you've posted is not an answer, and neither is it formatted correctly.
Your answer
Follow this Question
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