Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Unknown Error Message

Unknown Error Message

Scheduled Pinned Locked Moved C#
helptutoriallearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JMOdom
    wrote on last edited by
    #1

    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; } }

    K J V 3 Replies Last reply
    0
    • J JMOdom

      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; } }

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Well, it is a possibility that you accidentily named an object string. Try changing it to String and see if it works. Hope that helps. Ben

      1 Reply Last reply
      0
      • J JMOdom

        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; } }

        J Offline
        J Offline
        Jon Sagara
        wrote on last edited by
        #3

        Post the rest of your class definition. That would be very helpful in determining what is wrong.

        Jon Sagara This is the stuff we'll drink on special occasions. To paraphrase my father-in-law, this is the kind of wine that results in kids. -- A friend Blog | Site | Articles

        1 Reply Last reply
        0
        • J JMOdom

          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; } }

          V Offline
          V Offline
          Vikram A Punathambekar
          wrote on last edited by
          #4

          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

          J 1 Reply Last reply
          0
          • V Vikram A Punathambekar

            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

            J Offline
            J Offline
            JMOdom
            wrote on last edited by
            #5

            :) 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(); } } }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups