Answer to Question #325552 in C# for Zarifa

Question #325552

Create a class named 'Student' with a string variable 'name' and an integer variable 'roll_no'. Assign the value of roll_no as '2' and that of name as "John" by creating an object of the class Student. (For C sharp)


1
Expert's answer
2022-04-07T17:37:50-0400
using System;

namespace class_student
{
    class Program
    {
        public class Student
        {
            public string name;
            public int roll_no;
        }
        
        public static void Main(string[] args)
        {           
            Student stud = new Student();
            stud.roll_no = 2;
            stud.name = "John";
            Console.WriteLine("roll_no: {0}", stud.roll_no);
            Console.WriteLine("name: {0}\n", stud.name);
            
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS