using System;

namespace studentObj

    class Student
    {
        private int id ();
        private string name ();
        private char grade ();

        public int ID
        {
            get {return id;}
        }
        public string Name
        {
            get {return name;}
            set {name = value;}
        }
        public char Grade
        {
            get {return grade;}
        }

        public Student(int ID, string Name)
        {
            int id;
            string name;
        }

        public SetGrade(float score)
        {
            if (score>=90.0f)
                grade="A";
            else if (score>=80.0f)
                grade="B";
            else if (score>=70.0f)
                grade="C";
            else if (score>=60.0f)
                grade="D";
            else
                grade='F';
            return grade;
        }

        public override string ToString(){
        }
        class Kid
        {
            private int id { get; }
            private string name { get; set;}
            private char grade { get; }

            public override string ToString ()
            {
                return id + "," + name + "," + grade;
            }
        }
    }
    class MainClass
    {
        public static void Main (string[] args)
        {
            Student student = new Student (Name = "Jasdeep", ID = "234");
            SetGrade.student=75.0f;
            Console.WriteLine (student);
        }
    }
}

So... you just post some code... now what? Nobody here can read your mind to know what problems you are having with this code.
Explain your self! At least say what you're trying to do and where you are stuck at.

By the way, you are missing an '{' after your namespace declaration.

Edited 1 Year Ago by AleMonteiro

my bad, it says for the SetGrade block of code it needs a return type but when i put grade or score it gives me the error

It looks like you aren't returning anything in the ToString method right now, if you don't return something it will error out. Also, the SetGrade method does not have a return type specified. Should be "public float SetGrade(float score)".

Oh, ok. Should be like this:

 public string SetGrade(float score)
 {
     if (score>=90.0f)
        grade="A";
     else if (score>=80.0f)
        grade="B";
     else if (score>=70.0f)
        grade="C";
     else if (score>=60.0f)
        grade="D";
     else
        grade='F';

     return grade;
 }
This article has been dead for over six months. Start a new discussion instead.