Unknown Error Message
-
I have a property(See below) that should be working. This is in an example straight from my textbook. I have double and triple checked the coding after I typed it into the editor. I'm trying out the book example to see what the code looks like in the "real world". The editor is telling me "Expected class, delegate, enum, interface, or struct". :confused: I am getting that message from the error list with the "string" underlined. As I am new at this, I (at this time) do not understand exactly what I'm being told or how to fix it. Any help in that direction will be apreciated. :)
//Propertiy for the major data field public string Major { get { return major; } set { major = value; } }
-
I have a property(See below) that should be working. This is in an example straight from my textbook. I have double and triple checked the coding after I typed it into the editor. I'm trying out the book example to see what the code looks like in the "real world". The editor is telling me "Expected class, delegate, enum, interface, or struct". :confused: I am getting that message from the error list with the "string" underlined. As I am new at this, I (at this time) do not understand exactly what I'm being told or how to fix it. Any help in that direction will be apreciated. :)
//Propertiy for the major data field public string Major { get { return major; } set { major = value; } }
-
I have a property(See below) that should be working. This is in an example straight from my textbook. I have double and triple checked the coding after I typed it into the editor. I'm trying out the book example to see what the code looks like in the "real world". The editor is telling me "Expected class, delegate, enum, interface, or struct". :confused: I am getting that message from the error list with the "string" underlined. As I am new at this, I (at this time) do not understand exactly what I'm being told or how to fix it. Any help in that direction will be apreciated. :)
//Propertiy for the major data field public string Major { get { return major; } set { major = value; } }
-
I have a property(See below) that should be working. This is in an example straight from my textbook. I have double and triple checked the coding after I typed it into the editor. I'm trying out the book example to see what the code looks like in the "real world". The editor is telling me "Expected class, delegate, enum, interface, or struct". :confused: I am getting that message from the error list with the "string" underlined. As I am new at this, I (at this time) do not understand exactly what I'm being told or how to fix it. Any help in that direction will be apreciated. :)
//Propertiy for the major data field public string Major { get { return major; } set { major = value; } }
I'm sorry if my question is stupid, but are you sure your property definition is inside a class? Giving the class definition, with the irrelevant parts left out, might help.
Cheers, Vikram.
"But nowadays, it means nothing. Features are never frozen, development keeps happening, bugs never get fixed, and documentation is something you might find on wikipedia." - Marc Clifton on betas.
Join the CP group at NationStates. Password:
byalmightybob
-
I'm sorry if my question is stupid, but are you sure your property definition is inside a class? Giving the class definition, with the irrelevant parts left out, might help.
Cheers, Vikram.
"But nowadays, it means nothing. Features are never frozen, development keeps happening, bugs never get fixed, and documentation is something you might find on wikipedia." - Marc Clifton on betas.
Join the CP group at NationStates. Password:
byalmightybob
:) Thanks for your answers folks. I have found the solution (pardon the pun) to the problem. It seems that I had accidently typed in some code from the wrong page. X| Below I've listed my coding that works correctly. Thanks again. :-D
using System; using System.Collections.Generic; using System.Text; using PersonNameSpace; //Added to avoid using fully qualified names namespace StudentNameSpace { public class Student : Person { private string major; private int studentId; //Default constructor public Student() : base() //no arguments sent to base constructor { major = "unknown"; studentId = 0; } //Constructor that sends arguments to base class public Student(string id, string fname, string lname, string maj, int sId) : base(id, lname, fname) //base constructor arguments { major = maj; studentId = sId; } //Read only Property for studentId public int StudentId { get { return studentId; } } //Propertiy for the major data field public string Major { get { return major; } set { major = value; } } //Overrides GetSleepAmt() method of the Person class public override int GetSleepAmt() { return 6; } //Using the base keyword, calls the overridden // GetSleepAmt() method of the Person class public int CallOverriddenGetSleepAmt() { return base.GetSleepAmt(); } } }