hello all, I am new with C# and stuck on some coursework
I have created a class:
public class student
{ //start of class declaration
public string name="Jane Doe";
public string course="Multimedia and Internet Systems";
public string email="test@test.com";
}
how do I apply the class to a textbox so that when the user selects one of the details say name then the name will appear in the textbox.
or am i doing something completely wrong with the class
i am using MS Visual Studio .NET 2003
any help would be greatly appreciated
edit: i am using a main menu in the application, so when the user selects name from the menu it will display in the textbox

how do you apply a class
Naolin
rodri_ogri
runtime is occuring.
for some reason it doesnt seem to be recognising the name, course or email.
i get this error for each: the private field 'coursework4.Form1.student.name' is never used
DanielN305517
i have another problem though is the class I have created correct because the details are not being displayed when i run the app and click on one of the menu items.
dba_sql
It looks like a compile error, but actually, it does not even look like an error, it looks like a warning.
R2ks
A good debugging technique to see if you are properly suscribing to menu buttons event, is in the code add a quick message box: MessageBox.Show("HERE!");
This will let you know you made it to that area of your code (Using the debugger is a better technique but it is far more complicated to explain).
huabing78
can you use a switch case statement with a main menu
mahdi
well its compiling and the app is running but, those errors are still displaying.
it doesn't say anything about a build error.
i'm really sorry if i am making this more confusing than it is.
curtKauf
Srikanth Ramakrishnan
You will have the textbox you want the name in, well call it textBox1.
Now just make some function in the class that allows the user to select one of the three strings. Enumerations work nicely, but we will just use plain int,
void SelectDisplayItem(int item)
{
switch (item)
{
case 0:
textBox1.Text = name;
break;
case 1:
textBox1.Text = couse;
break;
case 2:
textBox1.Text = email;
break;
default:
textBox1.Text = "Invalid Selection";
break;
}
}