Tuesday, July 14, 2009

Help with C# Function Reference Declaration Error???????????

please please help my friend with this if you can hes been working so hard on this but hes stuck :/





I am trying to write a C# program for class and I know very little about C#. I have defined my function below the includes:





void Echo_Keypress(ulong_t arg);





and I am using my function later in the program:


static void Echo_Keypress(ulong_t arg)


{


//do stuff


}








This is the error I am getting:


main.c: (.text+0x9a): undefined reference to `Echo_Keypress'





Does anyone know how to get around this error? Any help/info is greatly appreciated

Help with C# Function Reference Declaration Error???????????
using System;


using System.Collections.Generic;


using System.ComponentModel;


using System.Data;


using System.Drawing;


using System.Text;


using System.Windows.Forms;





namespace jijo


{


public partial class Form1 : Form


{


public Form1()


{


InitializeComponent();


}





private void Form1_Load(object sender, EventArgs e)


{





}





private void Form1_KeyDown(object sender, KeyEventArgs e)


{


System.Windows.Forms.MessageBox.Show("Yo... press the key " + e.KeyCode.ToString());


}


}


}
Reply:Which of the two occurences of your function do you get the error on? I don't think in C# you have to declare a function like you would have to in C++.
Reply:See:





http://www.yoda.arachsys.com/csharp/para...





for the following topics:





Preamble: what is a reference type?


Further preamble: what is a value type?


Checking the preamble...


The different kinds of parameters


Value parameters


Reference parameters


Output parameters


Parameter arrays


Mini-glossary





Hope this helps.
Reply:Hi, You need not to declare your function as;


void Echo_keypress(ulong_t arg);





This is done normally in C++ or C style programming where you can declare functions before and give their definitions later on.





You just need to put your definition only, i.e.


static void Echo_keypress(ulong_t arg0


{


//do stuff


}





Also, as you are creating it as static, you will have to call it through class name directly, instead of creating a object first...


No comments:

Post a Comment